jesseledwards Posted April 10, 2007 Share Posted April 10, 2007 I really respect all of you for being such geniuses...I'm having an issue. I have 2 checkboxes, and I don't know if that's what is causing this error...They are named differently, but if someone could please help me again I would really appreciate it. Here's the error I get Error in query: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 ''subscribe, '')' at line 38 here's my code <?php /* grabs the POST variables and puts them into variables that we can use */ $firstName=$_POST['firstName']; $lastName=$_POST['lastName']; $company=$_POST['company']; $email=$_POST['email']; $website=$_POST['website']; $countryCode=$_POST['countryCode']; $phone=$_POST['phone']; $phoneExt=$_POST['phoneExt']; $mobile=$_POST['mobile']; $fax=$_POST['fax']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; $zipCode=$_POST['zipCode']; $heardAbout=$_POST['heardAbout']; $inquiring=$_POST['inquiring']; $MonthlyPlan=$_POST['MonthlyPlan']; $DesignStudy=$_POST['DesignStudy']; $textarea=$_POST['textarea']; //---------VALIDATION--------> if($firstName){//----> CHECK input } else{ $error.="Please, go back and fill out your first name\n";//----> ERROR if no input } if($lastName){//----> CHECK input } else{ $error.="Please, go back and fill out your last name\n";//----> ERROR if no input } if($email){//----> CHECK input } else{ $error.="Please, go back and fill out your e-mail address\n";//----> ERROR if no input } if($phone){//----> CHECK input } else{ $error.="Please, go back and fill out your phone number\n";//----> ERROR if no input } if($address){//----> CHECK input } else{ $error.="Please, go back and fill out your mailing address\n";//----> ERROR if no input } if($city){//----> CHECK input } else{ $error.="Please, go back and fill out your city name\n";//----> ERROR if no input } if($zipCode){//----> CHECK input } else{ $error.="Please, go back and fill out your zip code\n";//----> ERROR if no input } //-------->ERROR FREE?? if($error==""){ echo "Thank you for inquiring about us! A receipt of your submission will be e-mailed to you almost immediately."; //---------------------------------- $mailContent="--------CONTACT--------\n" ."First Name: ".$firstName."\n" ."Last Name: ".$lastName."\n" ."Company: ".$company."\n" ."E-mail: ".$email."\n" ."Website: ".$website."\n\n--------PHONE--------\n" ."Phone: ".$countryCode." ".$phone."\n" ."Extension: ".$phoneExt."\n" ."Fax: ".$fax."\n" ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n" ."Street Address: ".$address."\n" ."City: ".$city."\n" ."State: ".$state."\n" ."Country: ".$country."\n" ."Zip Code: ".$zipCode."\n\n--------INFO--------\n" ."Where did you hear about us? ".$heardAbout."\n" ."Inquiring About: ".$inquiring."\n" ."Monthly Plan: ".$MonthlyPlan."\n" ."Design Study Set: ".$DesignStudy."\n" ."Your Comments: ".$textarea."\n"; //---------------------------------- $toAddress="[email protected]"; $subject="Contact Information'"; $recipientSubject="Gravitas Contact Form"; $receiptMessage = "Thank you ".$firstName." for inquiring about Gravitas!\n\n\nHere is what you submitted to us:\n\n" ."--------CONTACT--------\n" ."First Name: ".$firstName."\n" ."Last Name: ".$lastName."\n" ."Company: ".$company."\n" ."E-mail: ".$email."\n" ."Website: ".$website."\n\n--------PHONE--------\n" ."Phone: ".$countryCode." ".$phone."\n" ."Extension: ".$phoneExt."\n" ."Fax: ".$fax."\n" ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n" ."Street Address: ".$address."\n" ."City: ".$city."\n" ."State: ".$state."\n" ."Country: ".$country."\n" ."Zip Code: ".$zipCode."\n\n--------INFO--------\n" ."Where did you hear about us? ".$heardAbout."\n" ."Inquiring About: ".$inquiring."\n" ."Monthly Plan: ".$MonthlyPlan."\n" ."Design Study Set: ".$DesignStudy."\n" ."Your Comments: ".$textarea."\n"; //---------------------------------- mail($email, $subject, $receiptMessage,"From:$toAddress"); //---------------------------------- mail($toAddress,$recipientSubject,$mailContent,"From:$email"); //--->echo $mailContent; //////////////////////////////////////// CONNECT TO MYSQL DB //////////////////// // OPEN CONNECTION ---> $connection=mysql_connect("****","****", "****") or die("Unable to connect!"); /* change this! */ mysql_select_db("****") or die("Unable to select database!"); // EXECUTE QUERY ---> $query="INSERT INTO generalContact ( firstName, lastName, company, email, website, countryCode, phone, phoneExt, mobile, fax, address, city, state, country, zipCode, inquiringOn, MonthlyPlan, DesignStudy) VALUES( '".$firstName."', '".$lastName."', '".$company."', '".$email."', '".$website."', '".$countryCode."', '".$phone."', '".$phoneExt."', '".$mobile."', '".$fax."', '".$address."', '".$city."', '".$state."', '".$country."', '".$zipCode."', '".$heardAbout."', '$inquiring', '$MonthlyPlan, '$DesignStudy')"; //////-----> $result=mysql_query($query) or die("Error in query:".mysql_error()); //if ($result) //echo mysql_affected_rows()." row inserted into the database effectively."; // CLOSE CONNECTION ---> mysql_close($connection); /////////////////////////////////////////////////////////////////////////////////// } else{ print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - \n"; print "$error\n"; print "\n"; print "\n"; print "Please use your \"Back\" button to return to the form to correct the omissions. Thank you.\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/46481-solved-i-need-some-basic-help/ Share on other sites More sharing options...
pocobueno1388 Posted April 10, 2007 Share Posted April 10, 2007 Looks like you are missing an apostrophe, Change this: '$MonthlyPlan To: '$MonthlyPlan' in your INSERT query. That may not solve the problem entirely...but it looks like that may be an issue. Link to comment https://forums.phpfreaks.com/topic/46481-solved-i-need-some-basic-help/#findComment-226112 Share on other sites More sharing options...
emehrkay Posted April 10, 2007 Share Posted April 10, 2007 to piggyback off of poc. why did you change the pattern from concatenation to including the var as apart of the string? Link to comment https://forums.phpfreaks.com/topic/46481-solved-i-need-some-basic-help/#findComment-226115 Share on other sites More sharing options...
pocobueno1388 Posted April 10, 2007 Share Posted April 10, 2007 Yeah...that was a question I had roaming through my head as I posted too. I forgot to put it though, hah. Link to comment https://forums.phpfreaks.com/topic/46481-solved-i-need-some-basic-help/#findComment-226118 Share on other sites More sharing options...
jesseledwards Posted April 10, 2007 Author Share Posted April 10, 2007 Ok...pocobueno. you're a genius! Thanks that fixed it. And I don't know to answer that other question...I'm not a coder by trade, as you probably noticed...I'm a graphic designer trying to make a simple update. So you just totally saved me!! Link to comment https://forums.phpfreaks.com/topic/46481-solved-i-need-some-basic-help/#findComment-226123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.