Re: Problem with WHERE clause in SELECT

From: Date: Thu, 22 Jun 2000 00:11:33 +0000
Subject: Re: Problem with WHERE clause in SELECT
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-565@lists.php.net to get a copy of this message
> The SQL query below returns no result from PHP though it works fine if I do > it thru telnet. The variable $email comes from a posted form and is set > correctly -- if I have echo $email in the same script it prints to screen an > email address that's in the database. > > Anybody know why? > > > $sql = "SELECT * FROM customer WHERE email = $email"; You probably need to make that: $sql = "SELECT * from customer WHERE email = '$email'"; Assuming email is not a numerical column in the database. > $result = mysql_query($sql, $db); > while ($myrow = mysql_fetch_array($result)) { > printf("%s %s %s\n", $myrow["firstname"], $myrow["lastname"], > $myrow["email"]); > } The rest looks ok. -Rasmus

« previous php.db (#565) next »