Parse error, not sure what to do.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Parse error, not sure what to do.

Post by Gappa »

Code i got from a phpfreaks tutorial and edited a bit... getting a Parse error: parse error in /data/hosted/Gappa/dor/contact.php on line 86

Pretty sure they will occur on line 87, 88 and 89 as well...

86 being

Code: Select all

$toAddress="gappamurphy@hotmail.com";
this I beileve..

really not sure what is wrong, can any body gimme a hand please? :)

Full script (if required)...

Code: Select all

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

<?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'];  
$address=$_POST['address']; 
$city=$_POST['city']; 
$state=$_POST['state']; 
$country=$_POST['country']; 
$postCode=$_POST['postCode'];  
$inquiring=$_POST['inquiring']; 

//---------VALIDATION---24-----> 
    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($postCode){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your post 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" 
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n" 
            ."Street Address: ".$address."\n" 
            ."City: ".$city."\n" 
            ."State: ".$state."\n" 
            ."Country: ".$country."\n" 
            ."Post Code: ".$postCode."\n\n--------INFO--------\n"  
            ."Inquiring About: ".$inquiring."\n" 
//---------------------------------- 
$toAddress="gappamurphy@hotmail.com";
$subject="Romeld Australia";
$recipientSubject="Romeld Australia"; 
$receiptMessage="Thank you ".$firstName." for inquiring about Romeld Australia!\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" 
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n" 
            ."Street Address: ".$address."\n" 
            ."City: ".$city."\n" 
            ."State: ".$state."\n" 
            ."Country: ".$country."\n" 
            ."Post Code: ".$postCode."\n\n--------INFO--------\n" 
            ."Inquiring About: ".$inquiring."\n" 
//---------------------------------- 
mail($email, $subject, $receiptMessage,"From:$toAddress"); 
//---------------------------------- 
mail($toAddress,$recipientSubject,$mailContent,"From:$email");

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

?> 
</body> 
</html>
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Code: Select all

<?php
$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" 
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n" 
            ."Street Address: ".$address."\n" 
            ."City: ".$city."\n" 
            ."State: ".$state."\n" 
            ."Country: ".$country."\n" 
            ."Post Code: ".$postCode."\n\n--------INFO--------\n"  
            ."Inquiring About: ".$inquiring."\n" 

?>
seems you didnt end the variable defining. wheres the ; ?
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Post by Gappa »

AHhh thanks!

There was another one of thsoe on line 106, thanks tim :)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Gappa I got to be honest with you, i really had to bust out the eagle eye on that, lol.

Your welcome, good luck :wink:
rajivkrishnang
Forum Newbie
Posts: 5
Joined: Tue Mar 23, 2004 12:18 am

Post by rajivkrishnang »

not the ans u seekin but another tip;

validate all usin clientside scripts ; when the form submit itself

y u r validating it after submiting the form; its not a good method of pgming

wil read ur mesage and revert back to u later;
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Heres the full script fixed... i think :\ Sorry im on th elibrary computers and they dont allow me to access my FTP not even in IE :bulb:, so sorry if it dont work. I just used the example that tim said and just fixed the rest. Hope it works :)

Code: Select all

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

<?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'];  
$address=$_POST['address']; 
$city=$_POST['city']; 
$state=$_POST['state']; 
$country=$_POST['country']; 
$postCode=$_POST['postCode'];  
$inquiring=$_POST['inquiring']; 

//---------VALIDATION---24-----> 
    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($postCode){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your post 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"; 
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"; 
            ."Street Address: ".$address."\n"; 
            ."City: ".$city."\n"; 
            ."State: ".$state."\n"; 
            ."Country: ".$country."\n"; 
            ."Post Code: ".$postCode."\n\n--------INFO--------\n";  
            ."Inquiring About: ".$inquiring."\n"; 
//---------------------------------- 
$toAddress="gappamurphy@hotmail.com"; 
$subject="Romeld Australia"; 
$recipientSubject="Romeld Australia"; 
$receiptMessage="Thank you ".$firstName." for inquiring about Romeld Australia!\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"; 
            ."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"; 
            ."Street Address: ".$address."\n"; 
            ."City: ".$city."\n"; 
            ."State: ".$state."\n"; 
            ."Country: ".$country."\n";
            ."Post Code: ".$postCode."\n\n--------INFO--------\n"; 
            ."Inquiring About: ".$inquiring."\n"; 
//---------------------------------- 
mail($email, $subject, $receiptMessage,"From:$toAddress"); 
//---------------------------------- 
mail($toAddress,$recipientSubject,$mailContent,"From:$email"); 

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


</body> 
</html>
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

yea, I would agree with raji - clientside validating is usually better. Use javascript to ensure that the form is filled in properly before allowing the user to submit it. a) it takes some work off the server and b) it makes it harder for users to screw it up
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Why use javascript? php is just as good, combine it with if statements to check for blank fields/whatever.

dale why even bother to test the code? Gappa already said it worked? heh
Post Reply