php change ' to '

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

php change ' to '

Post 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.
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: php change ' to '

Post by ldougherty »

What exactly are you trying to write it to? A database or output via HTML etc?
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

Re: php change ' to '

Post 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...
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: php change ' to '

Post 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
nmreddy
Forum Commoner
Posts: 25
Joined: Wed Feb 18, 2009 5:36 am

Re: php change ' to '

Post by nmreddy »

u can use addslashes function before inserting into database and stripslashes function before displaying the content in a page...
Post Reply