Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/03/2013, 11:07
mktalternativa
 
Fecha de Ingreso: enero-2012
Mensajes: 224
Antigüedad: 12 años, 3 meses
Puntos: 1
insertar xml en mysql

hola quiero guardar los datos de un xml en mi base de datos pero no logro hacer nada les pido una ayuda para ver que stoy haciendo mal , gracias

Mi problema es que el campo contenido tiene comilla simple ' y me devuelve error de sintaxys mysql que puedo hacer para que me reconozca el valor del mismo

Código PHP:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_localhost "localhost";
$database_localhost "usser";
$username_localhost "root";
$password_localhost "";
$localhost mysql_pconnect($hostname_localhost$username_localhost$password_localhost) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

<?php
    $xml
simplexml_load_file('archivo.xml');
    echo 
$amigo$xml->channel->item[0]->title;
    



$count=0;
foreach (
$xml->channel->item as $noticia) {  
    
// Inserta noticias en la tabla 
   
$qry "INSERT INTO noticias (titulo, contenido, diario) VALUES ('$noticia->title', '$noticia->description', '$noticia->author') " ;
    
      
mysql_select_db($database_localhost$localhost);
     
$result mysql_query($qry$localhost) or die(mysql_error());       
   }  
   
   
   
  
?>

Última edición por mktalternativa; 02/03/2013 a las 11:49