patheticsam Posted June 7, 2013 Share Posted June 7, 2013 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 = "rocky@email1.com"; $to2 = "pierre@email1.com"; $to3 = "john@email1.com"; } <--PARSE ERROR? elseif ($departement=='Ventes'){ $to1 = "sam@email1.com"; $to2 = "john@email1.com"; } elseif ($departement=='Recrutement'){ $to1 = "isaax@email1.com"; $to2 = "john@email1.com"; } $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 Quote Link to comment Share on other sites More sharing options...
dannon Posted June 7, 2013 Share Posted June 7, 2013 (edited) I believe your error states that it has found an unexpected '}'. You might have to many '}' somewhere. The code that you have posted doesn't give me any errors. Edited June 7, 2013 by dannon Quote Link to comment Share on other sites More sharing options...
patheticsam Posted June 7, 2013 Author Share Posted June 7, 2013 Well I gave to complete script. Thats the reason why I can't understand why I'm getting this error?? Quote Link to comment Share on other sites More sharing options...
dannon Posted June 7, 2013 Share Posted June 7, 2013 (edited) 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; Edited June 7, 2013 by dannon Quote Link to comment Share on other sites More sharing options...
requinix Posted June 7, 2013 Share Posted June 7, 2013 Well I gave to complete script.There's no opening <?php in what you posted. It's not the complete script. Quote Link to comment Share on other sites More sharing options...
dannon Posted June 7, 2013 Share Posted June 7, 2013 There's no opening <?php in what you posted. It's not the complete script. Also } <--PARSE ERROR? Doesn't look like line 21. Quote Link to comment Share on other sites More sharing options...
dalecosp Posted June 7, 2013 Share Posted June 7, 2013 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.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.