Note that there are some explanatory texts on larger screens.

plurals
  1. POINSERT fails on server with magic_quotes on
    text
    copied!<p>Ive been struggling to get my data to insert into my table. The data is pulled from an xml file into an array and echo'ing the results are fine but it fails on insertion. </p> <pre><code> $dbhost = 'XXXX'; $dbuser = 'XXXX'; $dbpass = 'XXXX'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); if($conn) { echo "Database Connection Successfull...&lt;br /&gt;&lt;br /&gt;"; } $dbname = 'a4027212_footy'; mysql_select_db($dbname) or die('Couldnt connect to database table'); if($dbname) { echo "Database ".$dbname." Selected..&lt;br /&gt;&lt;br /&gt;"; } $tweetmeme = "http://api.tweetmeme.com/stories/popular.xml?category=sports-soccer&amp;count=30" ; $xml = @simplexml_load_file($tweetmeme) or die ("no file loaded") ; if($xml) { echo "Tweetmeme XML loaded with ".count($xml-&gt;stories-&gt;story)." stories in the file..&lt;br /&gt;&lt;br /&gt;"; } if(get_magic_quotes_gpc()) { echo "Magic Quotes is ON&lt;br /&gt;&lt;br /&gt;"; } foreach($xml-&gt;stories-&gt;story as $story) { $title=$story-&gt;title; $title=mysql_real_escape_string($title); $url=$story-&gt;url; $url=mysql_real_escape_string($url); $media_type=$story-&gt;media_type; $media_type=mysql_real_escape_string($media_type); $created=$story-&gt;created_at; $created=mysql_real_escape_string($created); $url_count=$story-&gt;url_count; $url_count=mysql_real_escape_string($url_count); $comment_count=$story-&gt;comment_count; $comment_count=mysql_real_escape_string($comment_count); $excerpt=$story-&gt;excerpt; $excerpt=mysql_real_escape_string($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) or die(mysql_error()); if($result) { echo "added to database&lt;br /&gt;"; } } echo "&lt;br /&gt;&lt;br /&gt;"; </code></pre> <p>ive been told that insertion will fail if there are special characters in the string and mysql_real_escape_string() would help but it hasnt. Ive tried with and without escaping to no avail.</p> <p>the error message returned is:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'off. Ankle looks bad here. on Twitpic),mysql_real_escape_string(<a href="http://twitpic.c" rel="nofollow noreferrer">http://twitpic.c</a>' at line 1</p> <p>and it fails on the sql insertion.</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