Jump to content

Recommended Posts

I'm not 100% sure if this is to do with PHP or MySQL mainly, but probably it includes both :)

 

I'm trying to create a kind of guestbook/comment system on my website which is working pretty well so far, but I'm having one problem with \ when I'm inserting data into the MySQL database. Everytime I insert a word such as don't... it would come up in the database as don\'t. Then it also appears on the page that I've selected it for with don\'t which isn't very good. I know it's more than likely to make it so you can't break the code or something, but is there any way that when I select the data from the database, that it automatically gets rid of all the \s or something like that.

 

Thanks, Ashbow97 :)

Link to comment
https://forums.phpfreaks.com/topic/238462-annoying-s/
Share on other sites

If you're getting slashes actually inserted in the database, you aren't handling the data properly before inserting it. It's probably because magic_quotes_gpc is on, and you haven't checked for it before using mysql_real_escape_string().

 

if( get_magic_quotes_gpc() ) {
     $data = stripslashes($data);
     $data = mysql_real_eascape_string($data);
} else {
     $data = mysql_real_eascape_string($data);
}

Link to comment
https://forums.phpfreaks.com/topic/238462-annoying-s/#findComment-1225443
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.