Jump to content

inserting text


corillo181

Recommended Posts

when you insert text into mysql wich functions do you use to make sure the text is enter safely.. such functions as

 

htmlspecialchars that changes the html

 

mysql_real_escape_string

 

and others and to retrieve the text.

 

can any one give me some good functions to enter text the way the user enter it in their comment and make sure the text looks the same when it comes out of mysql.

Link to comment
Share on other sites

Inserting data

  • Definitely use mysql_real_escape_string() on EVERY variable being inserted into the database.
  • If you are allowing the user to insert HTML, use htmlentities() along with the above function.

 

Displaying data

  • If you used mysql_real_escape strings to put it into the DB, use striplashes() to display it.
  • If you used htmlentites() to put it in the db, use html_entity_decode() to display it.

 

Thats about all I know. There may be other things you could do to make it even safer.

 

 

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.