Re: Apostrophe's
| From: | Shrinivas-PPPindia | Date: | Thu, 10 Aug 2000 16:36:26 +0000 |
| Subject: | Re: Apostrophe's | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11178@lists.php.net to get a copy of this message | ||
Hi Dustin,
You can use "addslahes" a string function of php3
Which Returns a string with backslashes before characters that need
to be quoted in database queries etc. These characters are single
quote ('), double quote (") and backslash (\). {HYPERLINK
"function.stripslashes.html"} {HYPERLINK "function.quotemeta.html"}
eg.
$vx = girl's;
$vx = addslahes($vx);
print $vx;
will give you a output as girl\'s
sanshri
Send reply to: "Dustin Leggans" <dustinl@rocketmail.com>
From: "Dustin Leggans" <dustinl.rm@yahoo.com>
To: <php-general@lists.php.net>
Date sent: Wed, 9 Aug 2000 10:51:06 -0400
Subject: Apostrophe's
Hello...
Using PHP and MYSQL in various database projects, I have run into the
problem of having an apostrophe -- ' -- in a value.. For example, if
someone submits "Bob's Wharehouse" as a value for the column SUPPLIER, I
have to go in and either remove the apostrophe or "double" it ('') so it is
interpreted appropriately.
I have been doing this with the following code:
$NAME = strtr($NAME, "'", "''");
I am wondering if there is an easier way to take care of this problem. As I
am working with bigger database projects, it's becoming a real hassle to
have to do this for every variable. Maybe there is something different I can
do in my query string writing? Any suggestions will be much appreciated.
Thanks,
Dustin Leggans
dustinl@rocketmail.com
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
**** Sent through netMailshar - http://www.pppindia.com ****
Fast, easy-to-use mailserver