samoht Posted October 17, 2007 Share Posted October 17, 2007 hello, I am receiving this 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 'Kingston,Flintwood,PA,19082,213-209-9908,'A',date('YmdHis'),date('YmdHis'))' at line 2 When filling out a form. Here is the function that inserts the form info into my table <?php // save ship address $sql = "INSERT INTO clientaddresses(Name, Address1, City, State, Zip, Phone, FlagStatus, DateStatus, DateCreated) VALUES ($txtShippingLastName,$txtShippingAddress1,$txtShippingCity,$txtShippingState,$txtShippingPostalCode,$txtShippingPhone,'A',date('YmdHis'),date('YmdHis'))"; $result = dbQuery($sql); $_SESSION['ShipAddressId'] = $ShipAddressId = dbInsertId(); Any Ideas what's wrong with my insert?? Thanks Link to comment https://forums.phpfreaks.com/topic/73571-solved-error-in-syntax-help/ Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 lack of quotes $sql = "INSERT INTO clientaddresses(Name, Address1, City, State, Zip, Phone, FlagStatus, DateStatus, DateCreated) VALUES ('$txtShippingLastName','$txtShippingAddress1','$txtShippingCity','$txtShippingState','$txtShippingPostalCode','$txtShippingPhone','A',date('YmdHis'),date('YmdHis'))"; also check the date field Link to comment https://forums.phpfreaks.com/topic/73571-solved-error-in-syntax-help/#findComment-371183 Share on other sites More sharing options...
samoht Posted October 17, 2007 Author Share Posted October 17, 2007 thanks, I changed the dates to NOW() seems to work, but I need help with a concat, Is this right? VALUES(CONCAT('$txtShippingFirstName','','$txtShippingLastName'),etc Link to comment https://forums.phpfreaks.com/topic/73571-solved-error-in-syntax-help/#findComment-371203 Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 on an INSERT.. don't use CONCAT (theirs no need) use this (same as echo'ing) VALUES('$txtShippingFirstName $txtShippingLastName'),etc or even $FullName = "$first $surname"; VALUES('$FullName '),etc Link to comment https://forums.phpfreaks.com/topic/73571-solved-error-in-syntax-help/#findComment-371207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.