tags:

views:

80

answers:

6

What's wrong with the following SQL query?

$sql="SELECT * FROM ".TABLE." WHERE desgid='$id', weightid='$weightid' AND deptid='$deptid' ";

The error message is:

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 ' weightid='12' AND deptid='31'' at line 1

+6  A: 
SELECT * FROM ".TABLE." WHERE desgid='$id' AND weightid='$weightid' AND deptid='$deptid'
                                           ^
Quassnoi
+1  A: 

Try to change

WHERE desgid='$id', weightid='$weightid'

to

WHERE desgid='$id' AND weightid='$weightid'

and see.

shinkou
+2  A: 

There was not AND, try this:

$sql="SELECT * FROM ".TABLE." WHERE desgid='$id' and weightid='$weightid' AND deptid='$deptid' ";
Sarfraz
+2  A: 

It's the comma after the first where bit. Try

"SELECT * FROM ".TABLE." WHERE desgid='$id' AND weightid='$weightid' AND deptid='$deptid'"
MalphasWats
+2  A: 

You have a , in your SQL code after desgid='$id' try changing this to AND so your SQL code says:

$sql="SELECT * FROM ".TABLE." WHERE desgid='$id' AND weightid='$weightid' AND deptid='$deptid' ";
TommyA
+2  A: 

The comma is your problem:

desgid='$id', weightid =

ck