Jump to content

Archived

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

coopergl

You have an error in your SQL syntax

Recommended Posts

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

Share this post


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

Share this post


Link to post
Share on other sites
[code=php:0]
$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>');
  }

[/code]
Should also work... Not sure though

Share this post


Link to post
Share on other sites
You're absolutely right.  Changing the desc field name cured the problem.

Thanks very much.

Geoff.

Share this post


Link to post
Share on other sites

×

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.