Thanks for the suggestion but it's too ugly for me :-)  I'll just stick with
using '.  I don't forsee a problem.

- seb


-----Original Message-----
From: Moriyoshi Koizumi [mailto:[EMAIL PROTECTED]]
Sent: 25 July 2001 21:59
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Why doesn't this simple query work?


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?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to