RE: [PHP] Why doesn't this simple query work?

From: Date: Wed, 25 Jul 2001 20:14:53 +0000
Subject: RE: [PHP] Why doesn't this simple query work?
Groups: php.general 
Request: Send a blank email to php-general+get-59597@lists.php.net to get a copy of this message
> Driving me mad. Works if I put a string in quote marks instead of the > variable $location. > $result = mysql_query("SELECT shootID FROM shoots WHERE > (location=$location)"); > This should work shouldn't it? If it's a problem with the variable being > embedded in the query what's the easiest way to overcome this? $location is a string variable, yes? If so, then your statement needs to look like this: $result = mysql_query("SELECT shootID FROM shoots WHERE (location=\"$location\")"); Note the escaped quotes around $location. Chris

« previous php.general (#59597) next »