Jump to content


Photo

T_Variable... Wanting to understand more...


  • Please log in to reply
1 reply to this topic

#1 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 04 April 2006 - 08:30 PM

I'm uncertain as to why this doesn't work. I'm getting a T_Variable error. I'm building a contact form that submits the information to a database while emailing the form-ee and the person wanting to recieve this information.

<html>
<head>
</head>
<body>

<?php
/* grabs the POST variables and puts them into variables*/
$firstName=$_POST['firstName'];
$lastName=$_POST['lastName'];
$company=$_POST['company'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$phoneExt=$_POST['phoneExt'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zipCode=$_POST['zipCode'];
$heardAbout=$_POST['heardAbout'];
$inquiring=$_POST['inquiring'];

//---------VALIDATION-------->
    if($firstName){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input
            }

    if($lastName){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your last name<br>\n";//----> ERROR if no input
            }

    if($email){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your e-mail address<br>\n";//----> ERROR if no input
            }

    if($phone){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your phone number<br>\n";//----> ERROR if no input
            }

    if($address){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your mailing address<br>\n";//----> ERROR if no input
            }

    if($city){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your city name<br>\n";//----> ERROR if no input
            }

    if($zipCode){//----> CHECK input
        }
        else{
            $error.="Please, go back and fill out your zip code<br>\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"
            ."Contact me by: ".$company."\n"
            ."E-mail: ".$email."\n\n--------PHONE--------\n"
            ."Phone: ".$phone."\n"
            ."Extension: ".$phoneExt."\n"
            ."Fax: ".$fax."\n"
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"
            ."Street Address: ".$address."\n"
            ."City: ".$city."\n"
            ."State: ".$state."\n"
            ."Zip Code: ".$zipCode."\n\n--------INFO--------\n"
            ."Where did you hear about us? ".$heardAbout."\n"
            ."Inquiring About: ".$inquiring."\n"
//----------------------------------
$toAddress="whatever@gmail.com"; /* recieving address this isn't my address, fyi*/
$subject="Customer Inquiry"; /* email subject*/
$recipientSubject="Mountain East Real Estate"; /* recipient's subject */
$receiptMessage = "Thank you ".$firstName." for interest in Mountain East Real Estate.  You will be contacted back within 24 hours to assist with your needs.  If this is submitted on a weekend you will be contacted back on the next buisness day.\n\n\nHere is what you submitted to us:\n\n"
            ."--------CONTACT--------\n"
            ."First Name: ".$firstName."\n"
            ."Last Name: ".$lastName."\n"
            ."Contact me by: ".$company."\n"
            ."E-mail: ".$email."\n\n--------PHONE--------\n"
            ."Phone: ".$phone."\n"
            ."Extension: ".$phoneExt."\n"
            ."Fax: ".$fax."\n"
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"
            ."Street Address: ".$address."\n"
            ."City: ".$city."\n"
            ."State: ".$state."\n"
            ."Zip Code: ".$zipCode."\n\n--------INFO--------\n"
            ."Where did you hear about us? ".$heardAbout."\n"
            ."Inquiring About: ".$inquiring."\n"
//----------------------------------
mail($email, $subject, $receiptMessage,"From:$toAddress");
//----------------------------------
mail($toAddress,$recipientSubject,$mailContent,"From:$email");
//--->echo $mailContent;

////////////////////////////////////////  CONNECT TO MYSQL DB  ////////////////////
// OPEN CONNECTION --->
$connection=mysql_connect("localhost","user", "pass") or die("Unable to connect!"); /* kept general for security purposes */

mysql_select_db("generalContact") or die("Unable to select database!"); 

//  EXECUTE QUERY --->
$query="INSERT INTO generalContact (
            firstName,
            lastName,
            company,
            email,
            phone,
            phoneExt,
            mobile,
            fax,
            address,
            city,
            state,
            zipCode,
            heardAbout,
            inquiringOn)
        VALUES(
            '".$firstName."',
            '".$lastName."',
            '".$company."',
            '".$email."',
            '".$phone."',
            '".$phoneExt."',
            '".$mobile."',
            '".$fax."',
            '".$address."',
            '".$city."',
            '".$state."',
            '".$zipCode."',
            '".$heardAbout."',
            '".$inquiring."')";
//////----->
$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 - <br>\n";
            print "$error<br>\n";
            print "<br>\n";
            print "<br>\n";
            print "Please use your \"Back\" button to return to the form.  Thank you.<br>\n";
        }

?>
</body>
</html>

Parse error: syntax error, unexpected T_VARIABLE in /home/tornadop/www/www/MountainEast/contact_form.php on line 87

//the following line that is referencing the error is below

$toAddress="whatever@gmail.com"; /* recieving address this isn't my address, fyi*/

So I guess my question is three parts.
1) Why am I recieving this error?
2) How can I fix it? (i'm thinking it might have to do with using the @ symbol, but i'm not sure 100%)
3) And is this something stupid on my part in setting up the coding that I should avoid in the future?

Thanks in advance... guess i need to stop doing late night coding sessions.... lol
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#2 DrDre

DrDre
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 04 April 2006 - 08:31 PM

$mailContent="--------CONTACT--------\n"
            ."First Name: ".$firstName."\n"
            ."Last Name: ".$lastName."\n"
            ."Contact me by: ".$company."\n"
            ."E-mail: ".$email."\n\n--------PHONE--------\n"
            ."Phone: ".$phone."\n"
            ."Extension: ".$phoneExt."\n"
            ."Fax: ".$fax."\n"
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"
            ."Street Address: ".$address."\n"
            ."City: ".$city."\n"
            ."State: ".$state."\n"
            ."Zip Code: ".$zipCode."\n\n--------INFO--------\n"
            ."Where did you hear about us? ".$heardAbout."\n"
            ."Inquiring About: ".$inquiring."\n"


Forgot the ; at end of $mailcontent
[a href="http://forums.fanetworks.net" target="_blank"][/a]
» faNetworks Webmaster. [[a href="http://fanetworks.net" target="_blank"]fanetworks.net[/a]]
» faSoftware Developer [[a href="http://software.fanetworks.net" target="_blank"]software.fanetworks.net[/a]]
» faForums - php Resource + more [[a href="http://forums.fanetworks.net" target="_blank"]forums.fanetworks.net[/a]]
» Experienced php Coder - Ill help anyone I can if I have time ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users