CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 SQL Syntax Error (Pls Help)

Print topic Send  topic

Author Message
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.:-(:-(:-(
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.