July 28th, 2000, 08:44 PM
I've got a problem when using my PHP script with a mySQL database. It's so that I enter a text like for example in a table:
it's my comments blah blah
Then it gives me an error that I can't use the "'" sign, I've looked up pages but I haven't really found a good way to do this.
I'm using this for displaying different records with the user's personal information so I would like this invaild charater to be replaced before the user's page is viewed.
I've seen this made on other scripts but i'm not using a form of any kind yet but any suggestions are appreciated.
July 28th, 2000, 09:12 PM
escape it ! with a "" so simon's becomes simon's
Better still use addslashes() before you pass the data to the db , and stripslashes() when you call it back out.
if $str contains the contents of a text field with ' & " etc in it
$str=addslashes($str);//add to db//
when you get it back from the db