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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP MySQL Result - Session Variables

Status
Not open for further replies.

sipps

Technical User
Feb 9, 2003
133
GB
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())
 
So you put all that into a variable right? Echo that variable and see how it looks.

Post that as well, and things may be much more useful.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top