Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT query problem - session vars?

Status
Not open for further replies.

sipps

Technical User
Feb 9, 2003
133
GB
Hi all,

I am using PHP to write parts of my query to find a free car at a specific location with specific attributes such as Air_Con and Transmission and Fuel_Type. These values are passed from one page using session variables, along with the pick_up and drop_off dates and locations.

The dates and locations seem to work fine in teh quer, perhaps because they are integers or dates, but the air_Con, fuel_Type and transmission don't seem to affect the query at all and it brings back the same car reg whatever the input.

Here is the query:

SELECT DISTINCT vehicle.Vehicle_Registration
FROM vehicle LEFT JOIN booking
ON vehicle.Vehicle_registration = booking.Vehicle_Registration
WHERE Air_Con = '$HTTP_SESSION_VARS[Air_Con'
AND Fuel_Type = '$HTTP_SESSION_VARS[Fuel_Type]'
AND Transmission = '$HTTP_SESSION_VARS[Transmission]'
AND booking.Vehicle_Registration IS NULL
AND vehicle.Vehicle_Group_ID = '$_POST[Vehicle_Group_ID]'
AND Current_Location = '$HTTP_SESSION_VARS[Pick_Up_Location]' OR ('$HTTP_SESSION_VARS[Pick_Up_Date]' NOT BETWEEN Pick_Up_Date
AND Drop_Off_Date AND '$HTTP_SESSION_VARS[Drop_Off_Date]' NOT BETWEEN Pick_Up_Date AND Drop_Off_Date
AND Pick_Up_Date NOT BETWEEN '$HTTP_SESSION_VARS[Pick_Up_Date]' AND '$HTTP_SESSION_VARS[Drop_Off_Date]' AND Drop_Off_Date NOT BETWEEN '$HTTP_SESSION_VARS[Pick_Up_Date]' AND '$HTTP_SESSION_VARS[Drop_Off_Date]' AND '$HTTP_SESSION_VARS[Pick_Up_Date]' >= NOW())

Like I said, the date session_vars and location session_vars work fine and the right car comes back for that location and those dates, but the Air_Con doesn't affect it at all.

Even when I put the value 'Yes' or 'No', instead of '$HTTP_SESSION_VARS[Air_Con]' it doens't affect the query. Is this because of the LEFT JOIN?

I am quite new to MySQL so would really appreciate some help, this has been buggin me for days!!!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top