Re: Why doesn't this simple query work?
| From: | Moriyoshi Koizumi | Date: | Wed, 25 Jul 2001 20:58:38 +0000 |
| Subject: | Re: Why doesn't this simple query work? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59616@lists.php.net to get a copy of this message | ||
IMHO
$query = "SELECT shoodID FROM shoots WHERE location=\"$location\"";
and even
$query = "SELECT shoodID FROM shoots WHERE location='$location'";
sometimes cause SQL Syntax Error,
because the variable $location may contain quote characters (')(")...
since i experienced the same thing i've been doing like this...
(the reason is just that i did with 2 byte japanese characters?)
--------------------------------------------------------
$query = sprintf(
'SELECT shootID FROM shoots WHERE location="%s"',
AddSlashes( $location )
);
--------------------------------------------------------
going well, but is this code too ugry?