Page 1 of 1

Little problem understandign the WHERE clause

Posted: Mon Jun 19, 2006 6:56 pm
by a94060
Hi,im using this query to retrieve all results where the username is equal to $payee and the payed status s N,i think it is because i am not understaind the WHERE clause:

Code: Select all

$sql = "SELECT * FROM coffers WHERE username= $payee AND payed=N";
cansoemone just clear it up for me? i checked out in the manual and could not really udnerstand how to define the WHERE.

Posted: Mon Jun 19, 2006 6:58 pm
by Benjamin
If the variable isn't an integer it needs to be encapsulated in single quotes...

Code: Select all

$sql = "SELECT * FROM `coffers` WHERE `username`='" . $payee . "' AND `payed`='N'";

Posted: Mon Jun 19, 2006 7:45 pm
by a94060
ok,thanks,ill check that out tommorow.