1

I have some question about saving html code in mysql database every time when I put the charter " ' " in the database it changes to " / ".

Example: somthing like that

<p>That's my name</p>

After saving it look like this:

<p>That\'s my name</p>

what can i do? thank u all

Yossi Nagar
  • 87
  • 2
  • 10

3 Answers3

5
  • Use parameterized queries to escape data going into the database
  • Use nothing else to escape data going into the database (otherwise you will double escape which can use this problem)
    • Do not use mysql_real_escape_string
    • Do not use addslashes
    • etc
  • Do not escape data coming out of the database (since that will cause this problem)
  • Make sure magic quotes are disabled (since having them turned on will escape data going into and out of the database and cause this problem).
Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

You are using addslashes like escape functions in your code.

addslashes() — Quote string with slashes - http://php.net/manual/en/function.addslashes.php

stripslashes() — Un-quotes a quoted string - http://php.net/manual/en/function.stripslashes.php

Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
0

Use stripslashes to remove '\' from HTML data. Actually (') is used define string in MySql, so it ecaspe it (by putting \ in-front) in order to avoid any unintentional use.

Vivek Raj
  • 459
  • 5
  • 16