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')";
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'
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')";
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.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.