mkr365 Posted June 23, 2009 Share Posted June 23, 2009 Can anybody see something wrong with this code, cause i get an error on this query. i really can't find it $sql = "SELECT * FROM klantgegevens INNER JOIN rubrieken ON klantgegevens.Rubriek = rubrieken.RubriekID INNER JOIN groepen on rubrieken.GroepID = groepen.GroepID WHERE ".$bedrijfsnaam." ".$provincie." AND Rubriek = ".$categorien." AND groepen.Groepnaam = 'Architect' GROUP BY Bedrijfsnaam ORDER BY Bedrijfsnaam LIMIT ".($page*$numresults).", ".$numresults." "; Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
Maq Posted June 23, 2009 Share Posted June 23, 2009 This doesn't make sense to me. WHERE ".$bedrijfsnaam." ".$provincie." Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-861927 Share on other sites More sharing options...
mkr365 Posted June 23, 2009 Author Share Posted June 23, 2009 provincie is an default value wich is set. If i delete that part i receive the same syntax error Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-861934 Share on other sites More sharing options...
Maq Posted June 23, 2009 Share Posted June 23, 2009 provincie is an default value wich is set. If i delete that part i receive the same syntax error Well what's your error? Also, post your current query. If you delete the WHERE you have to change the first AND to a WHERE. Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-861944 Share on other sites More sharing options...
mkr365 Posted June 23, 2009 Author Share Posted June 23, 2009 This ois the 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 '', '7 AND groepen.Groepnaam = 'Architect' GROUP BY Bedrijfsnaam ORDER BY Bedrijf' at line 1 And this the query± if($_GET['categorien'] != "") $sql = "SELECT * FROM klantgegevens INNER JOIN rubrieken ON klantgegevens.Rubriek = rubrieken.RubriekID INNER JOIN groepen on rubrieken.GroepID = groepen.GroepID WHERE ".$bedrijfsnaam." ".$provincie." AND Rubriek = ".$categorien." AND groepen.Groepnaam = 'Architect' GROUP BY Bedrijfsnaam ORDER BY Bedrijfsnaam LIMIT ".($page*$numresults).", ".$numresults." "; I forgot to mention that it only goes wrong if i do a search with more than 1 categories. If i search on 2 categories together with an provincie than i get this error Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-861953 Share on other sites More sharing options...
kickstart Posted June 23, 2009 Share Posted June 23, 2009 Hi Can you echo out the sql string just before it is executed (ie, so we can see what it looks like once the variables are in it). All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-861999 Share on other sites More sharing options...
fenway Posted June 27, 2009 Share Posted June 27, 2009 That's correct -- you can't use = with two values; you'll have to use IN(). Quote Link to comment https://forums.phpfreaks.com/topic/163359-you-have-an-error-in-your-sql-syntax/#findComment-864762 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.