Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/07/2017, 17:51
jh0sz
 
Fecha de Ingreso: mayo-2010
Mensajes: 60
Antigüedad: 14 años
Puntos: 0
Consulta SQL para obtener datos de un campo

Hola amigos,

Estoy tratando de escribir un archivo XML a partir de la base de datos mysql, sin embargo me da el siguiente error:



Deduzco que es porque estoy haciendo la consulta SQL mal.

El código del script es:

Código:
<?php
header('Content-type: text/xml');

$xmlout = "<?xml version=\"1.0\" ?>\n";
$xmlout .= "<persons>\n";

$db = new PDO('mysql:host=xxx;dbname=xxxxxl','xxxx','xxx');
$stmt = $db->prepare("select * from wp_cf7dbplugin_submits");
$stmt->execute();
while($row = $stmt->fetch()){
 $xmlout .= "\t<person>\n";
 $xmlout .= "\t\t<rut>".$row['rut']."</rut>\n";
 $xmlout .= "\t\t<nombre>".$row['nombre']."</nombre>\n";
 $xmlout .= "\t\t<apellido>".$row['apellido']."</apellido>\n";
 $xmlout .= "\t\t<correo>".$row['correo']."</correo>\n";
 $xmlout .= "\t\t<telefonomovil>".$row['telefonomovil']."</telefonomovil>\n";
 $xmlout .= "\t\t<carrera>".$row['carrera']."</carrera>\n";
 $xmlout .= "\t</person>\n";
}

$xmlout .= "</persons>";
echo $xmlout;
?>
Base de datos:



Quedo atento,

Saludos