ddeile Posted October 14, 2006 Share Posted October 14, 2006 Hi,I've been working on a personal aggreagator project using php5's simpleXml api. Everything is working as expected except on one feed that I am parsing and entering into my database. The data in the <description> tags is not being sent to the database, nor am getting any mysql or php errors. Addionally, I can send the data in the <description> tags to the screen with no issues.Below is simplified version of my existing code. This works fine for any rss 2.0 feed that I have tried to parse. All except for feeds from engadet.com.[code].....after connecting to database.....$thisXml = simplexml_load_file("http://hdtv.engadget.com/rss.xml"); foreach($thisXml->channel->item as $item) { $date = date('Y-m-d h:i:s', strtotime($item->pubDate)); $query = mysql_db_query('feeds', "INSERT into feed_content (title, link, description, date) VALUES( '$item->title', '$item->link', '$item->description', '$date')"); } [/code]The database table `feeds` is structured as follows:[code]CREATE TABLE `feeds`.`feed_content` (`id` int( 11 ) NOT NULL AUTO_INCREMENT ,`title` varchar( 255 ) NOT NULL ,`link` varchar( 255 ) NOT NULL ,`description` text NOT NULL ,`date` datetime NOT NULL ,PRIMARY KEY ( `id` )) ENGINE = InnoDB DEFAULT CHARSET = latin1;[/code]What is interesting is that if I shorten $item->description by:[code]$description = substr($item->description,0,500);[/code]the data gets inserted into the table. But I wan't the entire <description> data inserted.Any idea what is going on? Again, I am not receiving any errors when this runs. Quote Link to comment Share on other sites More sharing options...
printf Posted October 14, 2006 Share Posted October 14, 2006 Your not escaping the insert! Always use die ( mysql_error () );, at least until you know you have it working right! Also always escape any insert you your self are not inserting!!![code] $query = mysql_db_query('feeds', "INSERT into feed_content (title, link, description, date) VALUES( '" . mysql_real_escape_string ( $item->title ) . "', '" . mysql_real_escape_string ( $item->link ) . "', '" . mysql_real_escape_string ( $item->description ) . "', '" . mysql_real_escape_string ( $date ) . "')");[/code]me! Quote Link to comment Share on other sites More sharing options...
ddeile Posted October 14, 2006 Author Share Posted October 14, 2006 Solved the issue. Thanks printf - I would have saved myself alot of time if I had used die ( mysql_error () ). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.