Page 1 of 1
php change ' to '
Posted: Mon May 11, 2009 6:10 pm
by tomsace
Is it possible to make a php form change the symbol ' to ' when submitted?
When I try to search for ' on google it changes it to a ' so I don't get the correct search results to help me out.
Thanks.
Re: php change ' to '
Posted: Mon May 11, 2009 6:25 pm
by ldougherty
What exactly are you trying to write it to? A database or output via HTML etc?
Re: php change ' to '
Posted: Mon May 11, 2009 6:43 pm
by tomsace
I am storing a description of games on my website, when I write ' it messes up the insertion of the mysql script so I have to write ' which works! I just wanted to be able to write ' insted of ' and the php script automatically change ' to ' before inserting into the database...
Re: php change ' to '
Posted: Mon May 11, 2009 6:48 pm
by ldougherty
If I understand you correctly you likely have a field that is writing to the database and the input includes ' which breaks the query.
You should check out mysql_real_escape_string which escapes special characters in a string for use in a SQL statement
http://us3.php.net/mysql_real_escape_string
Re: php change ' to '
Posted: Tue May 12, 2009 12:59 am
by nmreddy
u can use addslashes function before inserting into database and stripslashes function before displaying the content in a page...