Page 1 of 1

Query doesn't go through with AND syntax included

Posted: Sat Jul 10, 2004 12:24 pm
by EverToDesign
Hey, thanks for the read. Basically here it is. When I keep it as

$query = "SELECT asReportID, ADtransnum FROM $reports_table WHERE asReportID = '$controlnumber'
$order_by_str $sort_order_str $limit_str";


The search works fine

however there are multiple Agents so it needs to be more specific and grab only where the report iD is equal to $controlnumber and one other field the value of which is stored in session

$query = "SELECT asReportID, ADtransnum FROM $reports_table WHERE RAgency2 = '$_SESSION[id]' AND asReportID = '$controlnumber'
$order_by_str $sort_order_str $limit_str";

now I echoed out the $_SESSION[id] so I know its there and comes up as the appropriate value. Any ideas?

Edit> There was a typo in my last post. This is what the code looks like as above only ONE AND is there it still does not work though.

Posted: Sat Jul 10, 2004 12:29 pm
by kettle_drum
Theres too many AND's

Code: Select all

$query = "SELECT asReportID, ADtransnum FROM $reports_table WHERE RAgency2 = '$_SESSIONїid]' AND asReportID = '$controlnumber' $order_by_str $sort_order_str $limit_str";

Posted: Sat Jul 10, 2004 12:30 pm
by markl999
$query = "SELECT asReportID, ADtransnum FROM $reports_table WHERE AND RAgency2 = '$_SESSION[id]' AND asReportID = '$controlnumber'
$order_by_str $sort_order_str $limit_str";
Not sure if all that was a typo or not..but the syntax is..
SELECT ... FROM ... WHERE ... AND ... AND ..ORDER BY
you have
SELECT ... FROM ... WHERE AND ... AND ... ORDER BY

*beaten to it*