Jump to content


Photo

You have an error in your SQL syntax


  • Please log in to reply
3 replies to this topic

#1 coopergl

coopergl
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 August 2006 - 06:14 AM

Here's the whole error message:

Error fetching number details: 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 'desc FROM house_num WHERE house_num.id='1'' at line 1

This is the query that causes it:

$numb = @mysql_query(
    "SELECT number, desc FROM house_num WHERE house_num.id='$id'");
  if (!$numb) {
    exit('<p>Error fetching number details: ' .
        mysql_error() . '</p>');
  }

Any ideas what is wrong with this?

Using Mysql 4.0.27 and PHP 4.4.2

Thanks in advance

#2 logu

logu
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 08 August 2006 - 06:22 AM

Hi,
  I think the error is using the field "desc" it a keyword in sql for descending
  order .
  so change it to some thing and try


Regards
  logu

#3 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 07:05 AM

$numb = @mysql_query(
    "SELECT `number`, `desc` FROM `house_num` WHERE `house_num.id`='$id'");
  if (!$numb) {
    exit('<p>Error fetching number details: ' .
        mysql_error() . '</p>');
  }

Should also work... Not sure though
Why doesn't anyone ever say hi, hey, or whad up world?

#4 coopergl

coopergl
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 August 2006 - 04:03 PM

You're absolutely right.  Changing the desc field name cured the problem.

Thanks very much.

Geoff.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users