I have this SQL code
$sql = 'SELECT * FROM images WHERE
(artist LIKE "'.$artistsearch.'%")
AND (code LIKE "'.$idsearch.'%")
AND (name LIKE "'.$namesearch.'%")
AND (price BETWEEN '.$minprice.' AND '.$maxprice.')';
And I get the error
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND )' at line 5
However, running the code
SELECT *
FROM images WHERE artist LIKE '%'
AND code LIKE '%'
AND name LIKE '%'
AND price BETWEEN 0 AND 1000
Works fine in MySQL.
I've tried switching around ' and " and it doesn't work.
Can anyone help me figure out the problem?
$sqlvariable and see what's wrong.AND ), and that string doesn't appear in that code$maxpriceis empty$sql