Jump to content

Archived

This topic is now archived and is closed to further replies.

Viper76

MySQL / PHP problem, can someone help?

Recommended Posts

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 1

If 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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.