Jump to content


Photo

PHP script debugging


  • Please log in to reply
3 replies to this topic

#1 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 17 August 2006 - 08:25 PM

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.

"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"

can someone point out my mistake so I can smack myself upside the head

<?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();
?>


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 August 2006 - 08:31 PM

header="cc:me@me.com,bcc:you@you.com";

look into headers at php.net mail function ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 17 August 2006 - 08:32 PM

Change this line
<?php mysql_query($sql) or die ( mysql_error() ); ?>
to
<?php mysql_query($sql) or die ( "Problem with the query: $sql<br>" . mysql_error() ); ?>
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

#4 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 17 August 2006 - 08:36 PM

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



but thats crazy because it was just working!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users