Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase connecting but not inserting records?
    text
    copied!<p>Im putting together a simple script that pulls content from the tweetmeme api and then inserts it into a database for further formating. This is what i currently have but it inserts no records and returns no errors for the database connection so i can assume it connects and fails at the insertion.</p> <pre><code> $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = '****'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'footy'; mysql_select_db($dbname) or die('Couldnt connect to database table'); $tweetmeme = "http://api.tweetmeme.com/stories/popular.xml?category=sports-soccer&amp;count=30" ; $xml = @simplexml_load_file($tweetmeme) or die ("no file loaded") ; echo count($xml-&gt;stories-&gt;story)."stories in the XML file&lt;br /&gt;&lt;br /&gt;"; echo $xml-&gt;getName() . "&lt;br /&gt;&lt;br /&gt;"; foreach($xml-&gt;stories-&gt;story as $story) { $title=$story-&gt;title; $url=$story-&gt;url; $media_type=$story-&gt;media_type; $created=$story-&gt;created_at; //$current_time=$date(); $url_count=$story-&gt;url_count; $comment_count=$story-&gt;comment_count; $excerpt=$story-&gt;excerpt; $sql = "INSERT INTO ft_tweets (title,url,media_type,created_at,mention_count,comment_count,excerpt) VALUES ($title,$url,$media_type,$created,$url_count,$comment_count,$excerpt)"; $result = mysql_query($sql); </code></pre> <p>doing a vardump() on the various items returns "object(SimpleXMLElement)" and this is what the xml structure looks like for an example <a href="http://api.tweetmeme.com/stories/popular.xml?category=sports-soccer&amp;count=30" rel="nofollow noreferrer">link text</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload