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
https://forums.phpfreaks.com/topic/58021-inserting-text/
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
https://forums.phpfreaks.com/topic/58021-inserting-text/#findComment-287604
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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