Jump to content

[SOLVED] I need some basic help


jesseledwards

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.