musicmaker001 Posted August 17, 2013 Share Posted August 17, 2013 This is the SQL code I am using. SELECT mlsID, city, price, status, `class`, bedrooms, fullBaths, halfBaths, sqftHtd, remarks, levels, listOffice, virtualTour, `state`FROM 'dB'WHERE mlsID = 'mls' OR price BETWEEN 'priceLow' AND 'priceHigh' AND bedrooms >= 'beds' AND fullBaths >= 'baths' AND city LIKE '%"city"', sqftHtd >= 'sqft'ORDER BY price, city; There are variables passed to this query from the preceeding search page. (mls, priceLow, priceHigh, beds, baths, city and sqft) When I process the form I get this error. 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 ''RESIDENTIAL' WHERE mlsID = NULL OR price BETWEEN '200000' AND '400000' AND bedr' at line 1 I have been trying to solve this error for the last 3 hours, now it's time to seek the help of folks that are smarter than me! :-) Quote Link to comment https://forums.phpfreaks.com/topic/281270-snytax-error-in-a-complex-sql-query/ Share on other sites More sharing options...
darkfreaks Posted August 17, 2013 Share Posted August 17, 2013 (edited) you have an extra comma in your code and 'db' doesnt need single quotes around it. otherwise i think its fine. also do AND sqftHtd >= 'sqft' and not have a comma in between 2 AND Edited August 17, 2013 by darkfreaks Quote Link to comment https://forums.phpfreaks.com/topic/281270-snytax-error-in-a-complex-sql-query/#findComment-1445474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.