Re: Problem with WHERE clause in SELECT

From: Date: Thu, 22 Jun 2000 00:07:53 +0000
Subject: Re: Problem with WHERE clause in SELECT
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-564@lists.php.net to get a copy of this message
on 6/21/00 7:57 PM, Randy Perry at radknee@earthlink.net wrote: > 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"; > $result = mysql_query($sql, $db); > while ($myrow = mysql_fetch_array($result)) { > printf("%s %s %s\n", $myrow["firstname"], $myrow["lastname"], > $myrow["email"]); > } > > Oops. Never mind. I figured out I need to quote the $email variable. -- Randy Perry rgp systems Mac Consulting/Sales

« previous php.db (#564) next »