KeyVision
Posts: 18
|
| Posted: 04/15/2008, 2:41 PM |
|
Please help, I've tried everything, but cannot get my custom SQL insert to work.
I've got some code that collects field values from a Grid to insert into a table, but I keep getting the following error:
Database error: Invalid SQL: INSERT INTO vehicle_otions (field, option) VALUES ('Colour', 'Black')
MySQL Error: 1064 (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 'option) VALUES ('Colour', 'Black')' at line 1)
Session halted.
The code performing the insert is as follow:
global $fields;
$db = new clsDBConnection1();
for ($j = 1; $j <= $fields->PageSize + $form_name->EmptyRows; $j++)
if (strlen(CCGetParam("field_name_" . $j, ""))!=0 ) {
$field = CCGetParam("field_name_" . $j, "");
$option = CCGetParam("ListBox2_" . $j, "");
$SQL = "INSERT INTO vehicle_otions (field, option) ".
"VALUES (". $db->ToSQL($field,ccsText) .",
". $db->ToSQL($option,ccsText) .")";
//echo $SQL;
$db->query($SQL);
}
else
unset($db);
Could someone please help me debug this piece of code as I'm pulling my hair out. 
|