Ver Mensaje Individual
  #8 (permalink)  
Antiguo 08/02/2014, 12:05
tdcp
 
Fecha de Ingreso: febrero-2014
Ubicación: Madrid
Mensajes: 19
Antigüedad: 10 años, 2 meses
Puntos: 0
Respuesta: Extraer datos de otra web

lolaina me devuelve este error:
Warning: PDOStatement::execute() expects parameter 1 to be array, string given in /home/ubicator/public_html/ext.php on line 52.
Siguiendo las indicaciones, el código ha quedado así:
Código PHP:
Ver original
  1. <?php    
  2.     $extrae = $_POST['url'];
  3.     $provincias = $_POST['county'];
  4.     $paises = $_POST['country'];
  5.     // Use internal libxml errors -- turn on in production, off for debugging
  6.     // Createa a new DomDocument object
  7.     $dom = new DomDocument;
  8.     // Load the HTML
  9.     $dom->loadHTMLFile($extrae);
  10.     // Create a new XPath object
  11.     $xpath = new DomXPath($dom);
  12.     //Query all <td> nodes containing specified class name
  13.     $titulos = $xpath->query('//a[@class="url"]|//p[@class="tel"]|//span[@class="street-address"]|//a[@class="locality"]|//span[@class="latitude hidden"]|//span[@class="longitude hidden"]');
  14.     // Set HTTP response header to text/html for debugging output
  15.     header('Content-type: text/html; charset=utf-8');
  16.  
  17. $username = 'mi_usuario';
  18. $password = 'mi_contraseña';
  19. $connection = new PDO('mysql:host=localhost;dbname=mi_base_datos', $username, $password);
  20.  
  21. $statement = $connection->prepare('INSERT INTO markersprueba (name, phone, address, city, lat, lng) VALUES(?,?,?,?,?,?)');
  22.  
  23. foreach ($titulos as $titulo){
  24.     $statement->execute($titulo->nodeValue);
  25. }
  26. ?>

¿En que estoy fallando?