anthonydamasco Posted August 17, 2006 Share Posted August 17, 2006 I tried everything, I am utterly lost a frustrated with this script.The function of this script is to enter information into a database, and send 2 emails out, there are some required field, if-then statements. Everything was working until I added a second email scripts, I get a SQL santax error, but I have error reporting on next to everyone SQL script."[b]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 '''' at line 1[/b]"can someone point out my mistake so I can smack myself upside the head[code=php:0]<?php$conn = mysql_connect("localhost","useruser","thepassword") or die ( mysql_error() );$db = mysql_select_db("muhdatabase") or die ( mysql_error() );$usedbefore=""; $nearestlocation="";$companyname=""; $firstname=""; $lastname="";$department=""; $phone=""; $fax="";$address=""; $addresstwo=""; $city=""; $state=""; $country=""; $zip=""; $positiontype=""; $dressreq="";$dresscode=""; $positionclassification="";$positiontitle=""; $employeesneeded=""; $timeneeded=""; $startdate="";$workinghours="";$workAddress="";$workaddresstwo=""; $workcity="";$workstate=""; $workzip=""; $positiondescription="";$skillsrequired="";$educationrequired=""; $additionalrequirements="";$email="";$checkedby="";$hourlyrate="";$reportto="";$usedbefore = $_POST['current_client'];$nearestlocation = $_POST['branch'];$companyname = $_POST['company_name'];$firstname = $_POST['contact_first_name'];$lastname = $_POST['contact_last_name'];$department = $_POST['department'];$phone = $_POST['telephone'];$fax = $_POST['fax'];$email = $_POST['email_address'];$address = $_POST['addressone'];$addresstwo = $_POST['addresstwo'];$city = $_POST['city'];$state = $_POST['state'];$country = $_POST['country'];$zip = $_POST['zip'];$positiontype = $_POST['position_type'];$dressreq = $_POST['dressreq'];$dresscode = $_POST['dresscode'];$positionclassification = $_POST['position_classification'];$positiontitle = $_POST['position_title'];$employeesneeded = $_POST['number_of_employees_needed'];$timeneeded = $_POST['duration'];$startdate = $_POST['start_date'];$workinghours = $_POST['working_hours'];$workAddress = $_POST['work_addressone'];$workaddresstwo = $_POST['work_addresstwo'];$workcity = $_POST['work_city'];$workstate = $_POST['work_state'];$workzip = $_POST['work_zip'];$positiondescription = $_POST['position_description'];$skillsrequired = $_POST['skills_required'];$educationrequired = $_POST['education_required'];$additionalrequirements = $_POST['additional_requirements'];$checkedby = "no one";$hourlyrate = $_POST['hourlyrate'];$reportto = $_POST['reportto'];/* Do some error checking on the form posted fields */if((!$nearestlocation) || (!$lastname) || (!$email) || (!$phone)){ echo 'You did not submit the following required information! <br />'; if(!$nearestlocation){ echo "Nearest location is a required field. Please go back and correct this.<br />"; } if(!$companyname){ echo "Company Name is a required field. Please go back and correct this.<br />"; } if(!$firstname){ echo "First Name is a required field. Please go back and correct this.<br />"; } if(!$lastname){ echo "Last Name is a required field. Please go back and correct this.<br />"; } if(!$email){ echo "Email Address is a required field. Please go back and correct this.<br />"; } if(!$deparment){ echo "Department is a required field. Please go back and correct this.<br />"; } if(!$phone){ echo "Telephone number is a required field. Please go back and correct this.<br />"; } exit(); // if the error checking has failed, we'll exit the script!} //insert the values$sql = "INSERT INTO joborder VALUES (NULL, '$usedbefore', '$nearestlocation', '$companyname', '$firstname', '$lastname', '$department', '$phone', '$fax', '$email', '$address', '$addresstwo', '$city', '$state', '$country', '$zip', '$positiontype', '$dressreq', '$dresscode', '$positionclassification', '$positiontitle', '$employeesneeded', '$timeneeded', '$startdate', '$workinghours', '$workAddress', '$workaddresstwo', '$workcity', '$workstate', '$workzip', '$positiondescription', '$skillsrequired', '$educationrequired', '$additionalrequirements', '$checkedby', '$hourlyrate', SYSDATE()), '$reportto'";mysql_query($sql) or die ( mysql_error() );if(!$sql){ echo 'There has been an error creating your order. Please contact the webmaster.';} else { $orderid = mysql_insert_id(); // Let's mail the branch Selected! $subject = "Rapid Response Form!"; $message = "Dear Accu Staff member, The client chose $nearestlocation as their nearest location. The Rapid Response form can be found at the following link http://www2.accustaffing.com/rrform.php?id=$orderid ORDER ID NUMBER : $orderid If there are any problems, email anthony.damasco@accustaffing.com"; mail($to, $subject, $message, "From: Accustaffing Webmaster<anthony.damasco@accustaffing.com>\n X-Mailer: PHP/" . phpversion()); // Let's Mail The customer $subjectsecond = "ACCU STAFFING Rapid Response Form!"; $messagesecond = "Dear Customer, Your Rapid Response Order Form has been send to the branch you selected. The fallowing is the contact information we have: ORDER ID NUMBER: $orderid NAME: $firstname EMAIL: $email PHONE: $phone BRANCH FORM WAS SENT TO: $nearestlocation If you have any questions call us at 1-800-437-ACCU (2228) and have the Order ID number ready for our representative."; mail($email, $subjectsecond, $messagesecond, "From: Accustaffing Webmaster<anthony.damasco@accustaffing.com>\n X-Mailer: PHP/" . phpversion());}mysql_close();?>[/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 17, 2006 Share Posted August 17, 2006 header="cc:me@me.com,bcc:you@you.com";look into headers at php.net mail function ok. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 17, 2006 Share Posted August 17, 2006 Change this line[code]<?php mysql_query($sql) or die ( mysql_error() ); ?>[/code]to[code]<?php mysql_query($sql) or die ( "Problem with the query: $sql<br>" . mysql_error() ); ?>[/code]This will show you the query if that's where it's having a problem.If that's not the problem, please tell us what problem you're having.Ken Quote Link to comment Share on other sites More sharing options...
anthonydamasco Posted August 17, 2006 Author Share Posted August 17, 2006 [b]Problem with the query: INSERT INTO joborder VALUES (NULL, '', 'test', '', 'dele', 'dele', 'dele', 'dele', '', 'anthony.damasco@accustaffing.com', '', '', '', '', '', '', '', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'no one', '', SYSDATE()), ''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 '''' at line 1[/b]but thats crazy because it was just working! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.