Jump to content

Unknown parse error


patheticsam

Recommended Posts

Hi there,

 

I'm new to php and I have a parse error with a really simple script which I can't understand why it's not working

 

Basically I have a contact form in which your select a departement, the department value is posted to the send.php file to send the mail and depending on the selected department, the destination email changes.

 

 

Here is the send.php script :

$departement = $_POST['departement'];
$nom = $_POST["name"];
$courriel = $_POST["email"];
$telephone = $_POST["phone"];
$message = $_POST["message"];

//change this to your email.

if($departement=='Informations'){

        $to1 = "[email protected]";
	$to2 = "[email protected]";
        $to3 = "[email protected]";

	
	 } <--PARSE ERROR?
	
elseif ($departement=='Ventes'){

        $to1 = "[email protected]";
	$to2 = "[email protected]";

	}

elseif ($departement=='Recrutement'){

$to1 = "[email protected]";
    $to2 = "[email protected]";

    }
	
	
    $from = $courriel;
    $subject = "Nouveau message recu de votre site web";

    //begin of HTML message
    $message = <<<EOF
<html>
  <body bgcolor="#FFFFFF">
<h1>Courriel Recu du site web</h1>
<br /><br />
Vous avez recu un nouveau courriel d'un client a partir de votre site web.<br />
Veuillez contacter le client dans les plus brefs delais.<br /><br />


Nom du client : $nom <br /><br />

Telephone : $telephone <br />
Courriel : $courriel <br /><br />
Departement : $departement<br />

Message du client : $message
  </body>
</html>
EOF;
   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

	    
    // now lets send the email.
if($departement=='Informations'){	
	
    mail($to1, $subject, $message, $headers);
	mail($to2, $subject, $message, $headers);
	mail($to3, $subject, $message, $headers);

	
	}
elseif ($departement=='Ventes'){

    mail($to1, $subject, $message, $headers);
	mail($to2, $subject, $message, $headers);


	}

elseif ($departement=='Recrutement'){

mail($to1, $subject, $message, $headers);
    mail($to2, $subject, $message, $headers);


    }	

?>

Here's the error I'm getting :PHP Parse error:  syntax error, unexpected '}' in /home3/centreau/public_html/contact-auto-doum-centre-auto-dumoulin/send.php on line 21

 

If anyone can help me out it would be really appreciated!

 

Thanks!1

Link to comment
https://forums.phpfreaks.com/topic/278909-unknown-parse-error/
Share on other sites

Well I gave to complete script. Thats the reason why I can't understand why I'm getting this error??

Well, I get no parse errors when I test your code. Make sure that you end all of your statements correctly and make sure that you have your curly braces placed in correct places. Make sure that all of your syntax is correct. Based on what you have posted, I cannot see what is wrong with your code.

I should mention that I have replaced the post values in my test to:

$departement = 'Informations';
$nom = 5;
$courriel = 4;
$telephone = 7;
$message = 4;
Link to comment
https://forums.phpfreaks.com/topic/278909-unknown-parse-error/#findComment-1434730
Share on other sites

I'm sure you're not Pathetic, Sam.

The only parse error in what you've posted is 1] the lack of the opening PHP declaration, and 2] the "pointer" which should be a comment:

 

<--PARSE ERROR?


If the parse error you quoted:

 

syntax error, unexpected '}'
is really what the server/debugger tells you, then you didn't cut and paste the code exactly as it exists in the problem installation....
Link to comment
https://forums.phpfreaks.com/topic/278909-unknown-parse-error/#findComment-1434749
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.