Jump to content

help with echo and insert in db


UnknownPlayer

Recommended Posts

Hi,

i insert in db with mysql_real_escape_string() function, but when i read i use this:

- htmlentities(stripslashes($value), ENT_QUOTES, "UTF-8") - for all fields but no textarea

- stripslashes($value) - for textarea, becouse when insert that textare, its tinymce, and have html tags

 

Is this right way ?

 

Link to comment
Share on other sites

If data is retrieved from the database with slashes in it, either it wasn't properly escaped when it was inserted, or something is adding the slashes after retrieval. magic_quotes_gpc or magic_quotes_runtime may be on, or you have something applying addslashes() to your data. If you view the data in phpMyAdmin or the MySQL command line client, are the slashes there or not?

Link to comment
Share on other sites

magic_quotes_gpc is on, so the data is being double escaped. You'll want to turn off magic_quotes_gpc in your php.ini file, and restart Apache. You may need to check with the host to see how to do that. Then you'll need to run an UPDATE query to get rid of the unnecessary slashes added to the data, or import it from a "clean" source.

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.