Re: escape characters

From: Date: Mon, 22 Mar 2004 07:29:28 +0000
Subject: Re: escape characters
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-33593@lists.php.net to get a copy of this message
On Mar 22, 2004, at 5:30 AM, matthew perry wrote:
I am trying to allow my users to enter quotes in their strings. For
instance instead of writing:    2 inch rod, they can write 2 " rod.  The problem is, of course, that " ends the string and all that is saved is any value before the ".  How do I get around this without using textarea?
Use a function like mysql_real_escape() when you store data in your database to escape all inserted data, which prevents SQL injection attacks along the way. I'm not sure if you mean, but since you are talking about textarea's I guess you want to know how to display quotes in an <input> field. This is quite simple: convert the quotes to valid HTML with htmlentities()... Please read the manual for more information about these functions. Hope this helps... Regards, Filip de Waard

« previous php.db (#33593) next »