Viper76 Posted July 4, 2006 Share Posted July 4, 2006 I am working on a page that will limit how many items are given to me by the database at one time, here is the line of code that I am for some reason having trouble with:$result = mysql_query("SELECT spic, name FROM $tb1 LIMIT $at, 1 WHERE cat1 = '$cat' OR cat2 = '$cat' OR cat3 = '$cat'",$db) or die(mysql_error());And this is the error I am getting: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 'WHERE cat1 = '116' OR cat2 = '116' OR cat3 = '116'' at line 1If I take out the LIMIT portion, it works fine, so I assume it has something to di with how, or where I added it. If someone could help, that would be just great, thanks for your time! Link to comment https://forums.phpfreaks.com/topic/13673-mysql-php-problem-can-someone-help/ Share on other sites More sharing options...
dptr1988 Posted July 4, 2006 Share Posted July 4, 2006 Have you tried displaying the MySQL query before using it? Read <A href="http://dptr1988.mooo.com/php_tips.php#tip_mysql">PHP Coding Tips</A> for some ideas on how to find the problem yourself Link to comment https://forums.phpfreaks.com/topic/13673-mysql-php-problem-can-someone-help/#findComment-53040 Share on other sites More sharing options...
Viper76 Posted July 4, 2006 Author Share Posted July 4, 2006 instead of running it as a query I changed it over to an echo, to see what was printing on the screen and found my problem, I was not properly defining $at before the string. Got it all fixed now, thanks though guys ;D Link to comment https://forums.phpfreaks.com/topic/13673-mysql-php-problem-can-someone-help/#findComment-53044 Share on other sites More sharing options...
Recommended Posts