Jump to content


Photo

MySQL / PHP problem, can someone help?


  • This topic is locked This topic is locked
2 replies to this topic

#1 Viper76

Viper76
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationToledo Ohio

Posted 04 July 2006 - 09:04 PM

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

#2 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 04 July 2006 - 09:15 PM

Have you tried displaying the MySQL query before using it?  Read <A href="http://dptr1988.mooo...#tip_mysql">PHP Coding Tips</A> for some ideas on how to find the problem yourself
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#3 Viper76

Viper76
  • New Members
  • Pip
  • Newbie
  • 5 posts
  • LocationToledo Ohio

Posted 04 July 2006 - 09:37 PM

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
Sean




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users