Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error confusion... plz help

Status
Not open for further replies.

bigbird3156

Programmer
Feb 20, 2001
183
0
0
AU
Hi everyone...

Does anyone know what this error means and how to fix it?

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 id=2' at line 1

Thanks

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
As the message says, your SQL syntax is wrong. Print/echo out the full statement.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
sorry zeland...Im a noob...

I have created a database with 4 recordsets in it...

I have created 4 different pages that delete specific records from each of the recordsets ... 3 of them work, the forth does not...

this fourth is where I get the above error from

They are all essentially copies of each other so I am really confused...

The error seems to me to say that there is an error in the database setup? is that correct? or is it in the code of the php page??? I don't know where to look for the error

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
I'd be confused too if I can't see the "how" & "what". Start by showing us the section of your problematic PHP code and a sample of your data.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
The Error refers to your query. not the Db setup or anything else.

but we'll need to see the full query or at least the PHP code that generates it to help more.


That best we can do with this amount of information is tell you to look in the query near the area the error is pointing to.

That being "WHERE id=2".





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ok....

I think this is the code that is causing the problem is

Code:
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
  $deleteSQL = sprintf("DELETE FROM ``admin`` WHERE id=%s",
                       GetSQLValueString($_GET['id'], "int"));

  mysql_select_db($database_CA_database, $CA_database);
  $Result1 = mysql_query($deleteSQL, $CA_database) or die(mysql_error());

  $deleteGoTo = "user_update.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));

There are only 3 fields in this recordset... 'id' which is the primary key... auto incremented field (smallint)

then there is 'user' and 'password'

so I guess we are looking like...

1 Peter password1
2 Bob password2
3 Sally password3

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
If you id column is an int, shouldn't WHERE id=%s be WHERE id=%d?

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
i tried changing that... no change

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
Overlooked it earlier, but can you change the double back tic ``admin`` to just `admin`?

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
WOOOO HOOOO!!!!!!!

I know I am getting my fictional characters mixed but I dunno what Bigbird does when he is excited ... maybe he just rollerskates around a bit doing the birdie dance...

so anyway all that to say thanks heaps that was it...

[wiggle]The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!![jester]
 
fyi you only need to use backticks where you must disambiguate the column or function name. for example mysql has a function called password so you calling a column 'password' leads to mysql getting confused as, in a query like this
Code:
select password from table
it does not know whether you are asking for a result from a function or a column.

by using backticks you disambiguate so that mysql knows that you are referring to a column
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top