Page 1 of 1

Parse error, not sure what to do.

Posted: Mon Mar 22, 2004 8:25 pm
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>

Posted: Mon Mar 22, 2004 9:07 pm
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 ; ?

Posted: Mon Mar 22, 2004 9:13 pm
by Gappa
AHhh thanks!

There was another one of thsoe on line 106, thanks tim :)

Posted: Mon Mar 22, 2004 9:16 pm
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:

Posted: Tue Mar 23, 2004 12:55 am
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;

Posted: Tue Mar 23, 2004 3:36 am
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>

Posted: Tue Mar 23, 2004 6:59 am
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

Posted: Tue Mar 23, 2004 4:53 pm
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