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.
Query doesn't go through with AND syntax included
Moderator: General Moderators
-
EverToDesign
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 11, 2003 9:38 am
Query doesn't go through with AND syntax included
Last edited by EverToDesign on Sat Jul 10, 2004 1:01 pm, edited 1 time in total.
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
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";Not sure if all that was a typo or not..but the syntax is..$query = "SELECT asReportID, ADtransnum FROM $reports_table WHERE AND RAgency2 = '$_SESSION[id]' AND asReportID = '$controlnumber'
$order_by_str $sort_order_str $limit_str";
SELECT ... FROM ... WHERE ... AND ... AND ..ORDER BY
you have
SELECT ... FROM ... WHERE AND ... AND ... ORDER BY
*beaten to it*