Jump to content

Error in SQL Syntax


yarub

Recommended Posts

I made a really simple shoutbox, and I'm getting an error when apostrophes, quotation marks, and other php-recognized characters are used.

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 't know anything.'

What was typed was: I don't know anything.

How can I allow those characters? Here's what I'm using to input it:

[code]$add_info = "insert into shoutbox values ('', '$user', '$date', '$ip', '$_POST[content]', '1')";
mysql_query($add_info,$conn) or die(mysql_error());[/code]
Content is the field it's erroring. Help please.

._.
Link to comment
https://forums.phpfreaks.com/topic/12322-error-in-sql-syntax/
Share on other sites

You can either escape them with a backslash, or use their HTML entity instead.

[code]INSERT INTO `table` (`id`,`something`) VALUES ('1','There\'s a hole in my pocket')[/code]
[code]INSERT INTO `table` (`id`,`something`) VALUES ('1','There&#39:s a hole in my pocket')[/code]
{Replace the colon with a semi-colon in &#39:)
Link to comment
https://forums.phpfreaks.com/topic/12322-error-in-sql-syntax/#findComment-47088
Share on other sites

[!--quoteo(post=385414:date=Jun 18 2006, 09:22 PM:name=yarub)--][div class=\'quotetop\']QUOTE(yarub @ Jun 18 2006, 09:22 PM) [snapback]385414[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Oh. I knew that too. Haha. Thanks a lot for your help.
[/quote]
No problem [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
Link to comment
https://forums.phpfreaks.com/topic/12322-error-in-sql-syntax/#findComment-47098
Share on other sites

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.