Hi,
I have a search query for one of my pages, which searches for a car based on what the user has input, ie pick up date, pick up location, drop off date, drop off location and extras, such as air con, automatic/manual etc.
The search works great for dates, times and location id's, but when I use session variables in the query to search for cars with air/con, transmission type etc, it doesn't seem to work on what it was given. Is this because it is a string not an integer or date like the other search paramters?
The value of one session variable is:
$HTTP_SESSION_VARS[Air_Con] where air con is either Yes or No.
Do I have to escape that part of the query some how?
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())
I have a search query for one of my pages, which searches for a car based on what the user has input, ie pick up date, pick up location, drop off date, drop off location and extras, such as air con, automatic/manual etc.
The search works great for dates, times and location id's, but when I use session variables in the query to search for cars with air/con, transmission type etc, it doesn't seem to work on what it was given. Is this because it is a string not an integer or date like the other search paramters?
The value of one session variable is:
$HTTP_SESSION_VARS[Air_Con] where air con is either Yes or No.
Do I have to escape that part of the query some how?
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())