Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

In my PHP code I have a variable $message which includes the message to be sent to me which has post variables in it. It is supposed to have a semicolon at the end...but it gives me an error saying it is unexpected but I know I need it because it wont work without it. I am at a complete loss. Hopefully someone here can help me.

Error Message:

PHP Parse error:  syntax error, unexpected ';'

PHP Code

if(!empty($_POST["name"]) && !empty($_POST["address"]) && !empty($_POST["city"]) && !empty($_POST["phone"]) && !empty($_POST["email"]) && !empty($_POST["type"]))
{
$message = "Name:" . $_POST["name"] . 
"Address:" . $_POST["address"] . 
"City:" . $_POST["city"] . 
"State:" . $_POST["state"] . 
"Zip Code:" . $_POST["zip"] . 
"Phone:" . $_POST["phone"] . 
"Email:" . $_POST["email"] . 
"Current Roof Type:" . $_POST["type"] . 
"Roof Age:" . $_POST["age"] .
"Is it leaking?:" . $_POST["leak"] . 
"Does it have hail damage?:" . $_POST["hail"] . 
"Insurance:" . $_POST["insurance"] . 
"Additional Comments:" . $_POST["extra"] . 
;                                          <---------------####Unexpected semicolon
$to = "emailasdasdasdasd";
$subject = "Free Estimate";
$from = "Guarantee Roofing";
$headers = "From:" . $_POST["name"];
mail($to,$subject,$message,$headers);
}
share|improve this question

closed as too localized by StaticVariable, Anirudh Ramanathan, tereško, RichardTheKiwi, Peter O. Oct 19 '12 at 1:04

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

here is the problem

 "Additional Comments:" . $_POST["extra"] . 
 ;

should be

  "Additional Comments:" . $_POST["extra"]   ;
share|improve this answer
    
Wow, just that small of a problem...thank you though! – Spencer May Oct 18 '12 at 18:36
    
@SpencerMay yours very welcome .... – NullPoiиteя Oct 18 '12 at 18:38
"Additional Comments:" . $_POST["extra"] .  
                                         ^

Unnecessary concatenation operator -----------------here.

PHP is expecting a string/variable next to the concatenation operator and finds semicolon, which is reported unexpected.

share|improve this answer
"Additional Comments:" . $_POST["extra"] . 
                                         ^---- dangling concatenation
;  

you're telling PHP to concatenate a couple strings, and then terminate the statement without providing the second string.

share|improve this answer

There's an extra dot at the end of the string, if you delete the line breaks, you'd end up with

 ... . "Additional Comments:" . $_POST["extra"] . ;
share|improve this answer

You don't need that extra . after the last line which is implying concatenation.

Remove the . after this line:

"Additional Comments:" . $_POST["extra"] .
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.