View Single Post
Old 02-28-2008, 12:50 AM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

The problem there is that you are not wrapping $search_artist and $search_title in single quotes within your SQL statement.

For example, at the moment, MySQL sees your query as:

Code:
SELECT * FROM products WHERE cd_artist = a AND cd_title = b
Because the letters a and b are not wrapped in single quotes, MySQL assumes that they must be an SQL keyword. This doesn't happen when you use numbers because MySQL knows that a number is not an SQL keyword.

To resolve the problem, you need to wrap your variables in single quotes:

PHP Code:
$query "SELECT * FROM products WHERE cd_artist = '$search_artist' AND cd_title = '$search_title'"
MySQL would now see your query as:

Code:
SELECT * FROM products WHERE cd_artist = 'a' AND cd_title = 'b'
Which it understands

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
StevenF (02-28-2008)