titangf Posted April 4, 2006 Share Posted April 4, 2006 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.[code]<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="[email protected]"; /* 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> [/code][code]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="[email protected]"; /* recieving address this isn't my address, fyi*/[/code]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 Link to comment https://forums.phpfreaks.com/topic/6602-t_variable-wanting-to-understand-more/ Share on other sites More sharing options...
DrDre Posted April 4, 2006 Share Posted April 4, 2006 [code]$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"[/code]Forgot the ; at end of $mailcontent Link to comment https://forums.phpfreaks.com/topic/6602-t_variable-wanting-to-understand-more/#findComment-23965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.