02-28-2008, 12:50 AM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
|
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
|
|
|