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
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
Share on other sites

Is there a way to do that automatically? Like, when they submit their response, can I have my script change them automatically? I'm sure 99.9% of my users don't know ISO entities. >_<;
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.