kpetsche20 Posted April 7, 2008 Share Posted April 7, 2008 I'm trying to insert into a mysql database but I get 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 ' asdfsadfa)' at line 1 <?php function flipdate($dt, $seperator_in = '-', $seperator_out = '-') { return implode($seperator_out, array_reverse(explode($seperator_in, $dt))); } include ("config.php"); if ($_REQUEST['Submit'] == "Submit") { $dbase = mysql_connect($serverAddress,$serverUser,$serverPassword) or die("Could not connect to database"); mysql_select_db($serverDB); $type = str_replace("'","''",$_REQUEST['typee']); $make = str_replace("'","''",$_REQUEST['qmake']); $model = str_replace("'","''",$_REQUEST['qmodel']); $variant = str_replace("'","''",$_REQUEST['qvariant']); $purpose = str_replace("'","''",$_REQUEST['qpurpose']); $bizname=str_replace("'","''",$_REQUEST['bizNameV']); $term = str_replace("'","''",$_REQUEST['qterm']); $miles = str_replace("'","''",$_REQUEST['qmiles']); $cond = str_replace("'","''",$_REQUEST['qcondition']); $name = str_replace("'","''",$_REQUEST['name']); $email = str_replace("'","''",$_REQUEST['email']); $phone = str_replace("'","''",$_REQUEST['phone']); $addinfo = str_replace("'","''",$_REQUEST['addinfo']); $subject = "Select Vechicles Leasing - Quote Requested : ".$name ; $mybody = "Select Vechicles Leasing - Quote Requested : ".$name. "\r\n"; $mybody .= "Request Date : ".$today ."\r\n"; $mybody .= "Full Name : ".$name ."\r\n"; $mybody .= "Email Address : ".$email ."\r\n"; $mybody .= "Phone Number : ".$phone ."\r\n"; $mybody .= "Type : ".$type ."\r\n"; $mybody .= "Make : ".$make ."\r\n"; $mybody .= "Model : ".$model ."\r\n"; $mybody .= "Variant : ".$variant ."\r\n"; $mybody .= "Purpose : ".$purpose ."\r\n"; $mybody .= "Business Name (If Applicable): ".$bizname ."\r\n"; $mybody .= "Length of Contract : ".$term ."\r\n"; $mybody .= "Miles : ".$miles ."\r\n"; $mybody .= "Maintainance : ".$cond ."\r\n"; $mybody .= "Additional Information : \n\n".$addinfo ."\r\n"; $myheaders = "MIME-Version: 1.0\r\n"; $myheaders .= "Content-type: text/html; charset=iso-8859-1\r\n"; $myheaders .= "From: " . $name . "<" . $email . ">\r\n"; $upload = "INSERT INTO people (name, type) VALUES (".$type.", ".$phone.")"); mysql_query($upload) or die(mysql_error()); mail('[email protected]', 'test', $mybody); } ?> Link to comment https://forums.phpfreaks.com/topic/100052-mysql-error/ Share on other sites More sharing options...
Barand Posted April 7, 2008 Share Posted April 7, 2008 string values need to be in quotes $upload = "INSERT INTO people (name, type) VALUES ('$type', '$phone')"); Link to comment https://forums.phpfreaks.com/topic/100052-mysql-error/#findComment-511592 Share on other sites More sharing options...
kpetsche20 Posted April 7, 2008 Author Share Posted April 7, 2008 Thanks, that fixed it. Link to comment https://forums.phpfreaks.com/topic/100052-mysql-error/#findComment-511594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.