Re: Dealing with Quotation marks
| From: | Joe Van Meer | Date: | Mon, 11 Feb 2002 22:05:32 +0000 |
| Subject: | Re: Dealing with Quotation marks | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16831@lists.php.net to get a copy of this message | ||
Hi Gary, one way to get around this is by using two php functions,
addslashes() and sripslashes().
example:
form values:
$name = "O'Neil";
$name = addslashes($name);
echo $name;
Output would be: O\'Neil
For values coming out of db:
$address = "One Hundred Rancher\'s Way";
$address = stripslashes($address);
echo $address;
Output would be:One Hundred Rancher's Way
Use addslashes() upon db insertion and stripslashes() 'on the way out'.
hth Joe :)
Gary <gcooke@radionics.com> wrote in message
news:20020208163325.18997.qmail@pb1.pair.com...
> Does anyone know how to deal with this problem? If a user enters in a text
> box; O'Connor's 2" x 3" When you print it out on the next web page it
reads;
> O\'Connor\'s 2\" x 3\" I have written a function to take care of this, but
> when you try to write it to the database you get an error of unmatched
> quotation marks. Is there a function to handle this? Any help would be
> appreciated.
>
> Thanks, Gary
>
>