Jump to content

[SOLVED] SQL Syntax Problem W/ Apostrophe


refiking

Recommended Posts

Here's the error message:

 

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 's jewelrty rocks

here it is again!fff

)')' at line 1

 

Here's the code:

$sql = mysql_query("SELECT * FROM `textads` WHERE `text_ad_id` = '$text_ad_id'")or die(mysql_error());
while ($row = mysql_fetch_assoc($sql)){
$text_ad = stripslashes($row['text_ad']);
$type = $row['type'];
}
mysql_query("INSERT INTO `textads_backup` (`type`, `text_ad`) VALUES ('$type', '$text_ad')")or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/133943-solved-sql-syntax-problem-w-apostrophe/
Share on other sites

$text_ad = stripslashes($row['text_ad']);

 

You need slashes to escape the quotes, try removing the "stripslashes()" function.. or use "addslashes()" in the query ..

 

Adam

No, better to use mysql_real_escape_string in this situation.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.