jponte Posted February 20, 2010 Share Posted February 20, 2010 Hi, I can see that the query displays what I want and the values are passed correctly but I get the error: 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 'values ('1002090352', 'RMA999', '02/20/2010', '215-487-5545', 'RIM', '5544523', ' at line 1 The Query1 is: INSERT into values ('1002090352', 'RMA999', '02/20/2010', '215-487-5545', 'RIM', '5544523', '535486878787879', 'Purple', 'fgdfsdfgsdfgsdf', 'Y', 'Y', 'Y', 'Y', 'fdgdfgdsfgsdfg', '1') The code is as follows: if(!isset($ContactIDVal)){ $Query2 = "INSERT into $rma_devices values (NULL, '$ShipAttention', '$ShipPhone', '$ShipEmail', '$ShipStreet', '$ShipAddinfo', '$ShipCity', '$ShipProv', '$ShipPCode', '$ShipAddNotes')"; //Get the generated ID for Contact_ID $Gen_Contact_ID = mysql_insert_id(); echo $Gen_Contact_ID; $Query = "INSERT into $rma_devices values ('$RMANumber', '$CustomerID', '$RMADate', '$DevicePhone', '$DeviceType', '$DeviceModel', '$DeviceIMEI', '$DeviceColor', '$DescDefect', '$ResetDevice', '$SoftwareReload', '$WipeDevice', '$TroubOther', '$TroubNotes', '$Gen_Contact_ID')"; } else{ $Gen_Contact_ID = $contactinfo ['Contact_ID']; print ("<BR>Break: $Gen_Contact_Info<BR>\n"); $Query = "INSERT into $rma_devices values ('$RMANumber', '$CustomerID', '$RMADate', '$DevicePhone', '$DeviceType', '$DeviceModel', '$DeviceIMEI', '$DeviceColor', '$DescDefect', '$ResetDevice', '$SoftwareReload', '$WipeDevice', '$TroubOther', '$TroubNotes', '$Gen_Contact_ID')"; } if (!$link = mysql_connect('localhost', 'root', 'escrma')) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db('rma_portal', $link)) { echo 'Could not select database'; exit; } print ("<br>The Query2 is:<BR>$Query2<P>\n"); print ("<br>The Query1 is:<BR>$Query<P>\n"); if (mysql_db_query ($DBName, $Query, $Link)) { print ("The RMA form has been saved to the ESC database<br>\n"); } else {print ("There was a problem saving the RMA form to the database<br>Please contact ESC at 1-877-939-3282\n"); echo "<BR><BR>Error message = ".mysql_error(); } mysql_close ($Link); I checked the MYSQL table and everything is OK there. Thanks for your help Link to comment https://forums.phpfreaks.com/topic/192721-error-message-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 you forgot the table name insert into tablename values . .... Link to comment https://forums.phpfreaks.com/topic/192721-error-message-you-have-an-error-in-your-sql-syntax/#findComment-1015219 Share on other sites More sharing options...
PFMaBiSmAd Posted February 20, 2010 Share Posted February 20, 2010 Where is $rma_devices being set at? Link to comment https://forums.phpfreaks.com/topic/192721-error-message-you-have-an-error-in-your-sql-syntax/#findComment-1015220 Share on other sites More sharing options...
jl5501 Posted February 20, 2010 Share Posted February 20, 2010 ah, I think $rma_devices is meant to be rma_devices. Link to comment https://forums.phpfreaks.com/topic/192721-error-message-you-have-an-error-in-your-sql-syntax/#findComment-1015222 Share on other sites More sharing options...
jponte Posted February 20, 2010 Author Share Posted February 20, 2010 Hi, The table was a variable before which I changed for the table name. The $ remained. It works now. Thanks.... Link to comment https://forums.phpfreaks.com/topic/192721-error-message-you-have-an-error-in-your-sql-syntax/#findComment-1015226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.