Online Advertising - Repair Bad Credit - Myspace Generators - Mortgage Insurance - Online Advertising

PDA

View Full Version : You have an error in your SQL syntax; check the manual that corresponds to your MySQL


lost
Nov 1st 2005, 5:03 am
I'm getting the following error and have no idea what is wrong:

"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 'use, location, guardian, dateremoved, expectedreturndate, actual"

Here is my line of code:
$query = "INSERT INTO cca_assembly(description, partno, itemno, serno, barcode, manu, manupartno, manuserno, use, location, guardian, dateremoved, expectedreturndate, actualreturndate, notes) VALUES ('$desc', '$pno', '$ino', '$sno', '$brcd', '$mnu', '$mnupno', '$mnusno', '$iuse', '$loc', '$grdn', '$datermvd', '$exreturndate', '$actreturndate', '$ntshstry')";

dct
Nov 1st 2005, 5:18 am
use is a reserved word you need to wrap it in backticks (Ithink that's what their called) like this


INSERT INTO cca_assembly
(description, partno, itemno, serno, barcode, manu, manupartno,
manuserno, `use`, location, guardian, dateremoved, expectedreturndate,
actualreturndate, notes)
VALUES
('$desc', '$pno', '$ino', '$sno', '$brcd', '$mnu', '$mnupno', '$mnusno',
'$iuse', '$loc', '$grdn', '$datermvd', '$exreturndate', '$actreturndate',
'$ntshstry')

elkiwi
Nov 1st 2005, 5:23 am
Also make sure that you are using addslashes if those variables are coming from a form as that will cause errors with things like " elkiwi's "

lost
Nov 1st 2005, 5:41 am
Thanks guys, i just changed the name, the error is now gone, however i'm now getting this:

Unknown column 'usesearchtype' in 'field list'

dct
Nov 1st 2005, 5:44 am
Can you post the new SQL as I can't see the 'usesearchtype' in your original code.

lost
Nov 1st 2005, 6:05 am
$query = "INSERT INTO cca_assembly(description, partno, itemno, serno, barcode, manu, manupartno, manuserno, usesearchtype, locsearchtype, grdnsearchtyp, dateremoved, expectedreturndate, actualreturndate, notes) VALUES ('$desc', '$pno', '$ino', '$sno', '$brcd', '$mnu', '$mnupno', '$mnusno', '$iuse', '$loc', '$grdn', '$datermvd', '$exreturndate', '$actreturndate', '$ntshstry')";

dct
Nov 1st 2005, 6:10 am
INSERT INTO cca_assembly
(description, partno, itemno, serno,
barcode, manu, manupartno, manuserno,
usesearchtype, locsearchtype,
grdnsearchtyp, dateremoved,
expectedreturndate, actualreturndate, notes)
VALUES ('$desc', '$pno', '$ino', '$sno', '$brcd',
'$mnu', '$mnupno', '$mnusno', '$iuse', '$loc',
'$grdn', '$datermvd', '$exreturndate',
'$actreturndate', '$ntshstry');

Does the column usesearchtype even exist?

lost
Nov 1st 2005, 6:21 am
Sorry my bad, i forgot to change use in the database....

Thanks again guys.