yarub Posted June 18, 2006 Share Posted June 18, 2006 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.._. Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 18, 2006 Share Posted June 18, 2006 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':s a hole in my pocket')[/code]{Replace the colon with a semi-colon in ':) Quote Link to comment Share on other sites More sharing options...
yarub Posted June 18, 2006 Author Share Posted June 18, 2006 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. >_<; Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 18, 2006 Share Posted June 18, 2006 You can convert to entities with htmlentities() or you can escape the quotes with str_replace() Quote Link to comment Share on other sites More sharing options...
yarub Posted June 18, 2006 Author Share Posted June 18, 2006 Oh. I knew that too. Haha. Thanks a lot for your help. Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 18, 2006 Share Posted June 18, 2006 [!--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\" /] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.