PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Jun 23, 2018 6:31 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Dec 17, 2017 10:32 am 
Offline
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 197
Folks,

Do you spot any logical errors in my script ?
I have not given the full script but the SendMail part where I am encountering problem.

I get error:
Parse error: syntax error, unexpected '"' in /home/...... on line 155.

Line 155 is the line before the <html> tag. That line shows this:
$body = "$first_name." ".$surname ?>,

Look at the 5th line from the following code. That is where the error occurs:

Syntax: [ Download ] [ Hide ]
$account_name = "$username";
                    //Step 3C. Email user their account activation link for them to click to confirm their Email Address and activate their new Account.
                    $to = "$primary_website_email";
                    $subject = "Your Following Browser activation details!";
                    $body = "$first_name." ".$surname ?>,
                    <html>
                    <head>
                    <title>Activation Link</title>
                    </head>
                    <body>
                    Thank you for joining us!<br>
                    You need to click on the following link <a href="<?php .$account_activation_link.">$account_activation_link?></a> to activate your account.
                    </body>
                    </html>"
;
                    <?php $headers = "From: $site_admin_email";
                    //More headers
                    //Always set content-type when sending HTML email
                    $headers = "MIME-Version: 1.0" . "\r\n";
                    $headers .= "Content-type:text/html;charset=UTF-9" . "\r\n";
                     
                    if (!mail($to,$subject,$body,$headers))  
                    {
                        //Alert user System Error. System unable to email the Account Activation Link.
                        echo "Sorry! We have failed to email you your account activation details. Please contact the website administrator!";
                        exit();
                    }
                    else
                    {
                        //Alert user System Success. System was able to email the Account Activation Link.
                        echo "<h3 style='text-align:center'>Thank you for your registration!</h3><br>";
                        echo "Now, check your email \"$primary_website_email\" for details on how to activate your new account \"$account_name\" which you just registered.";
                        exit();
                    }
 


It is like this:

$body = "$first_name." ".$surname ?>,

The dbl quote prior to $first_name represents the opening dbl quote for the variable $body.
The 2 dbl quotes in between
$first_name.
.$surname
represent a space. (Space inbetween $first & $surname).
So, $firstname, concatenator, 2 dbl quotes representing the space, concatenator, $surname.
The closing dbl quote for the $body variable is right after the closing html tag (few lines below the $body variable).
I hope that is clear.
Therefore, I do not see any errors on this line:
$body = "$first_name." ".$surname ?>,
According to the error, one of these dbl quotes should not exist. It does not say which one but I'm guessing php is picking on the first one ALL for nothing.


Last edited by UniqueIdeaMan on Sun Dec 17, 2017 1:23 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Dec 17, 2017 1:23 pm 
Offline
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 197
I did not understand others' hints that you do not concatenate inside dbl quotes but sngl quotes only. 

Solved:
Syntax: [ Download ] [ Hide ]

                    $account_name = "$username";
                    //Step 3C. Email user their account activation link for them to click to confirm their Email Address and activate their new Account.
                    $to = "$primary_website_email";
                    $subject = "Your  account activation details!";
                    $body = "$first_name $surname ?>,
                    <html>
                    <head>
                    <title>Activation Link</title>
                    </head>
                    <body>
                    Thank you for joining us!<br>
                    You need to click on the following link <a href=\"$account_activation_link\">$account_activation_link</a> to activate your account.
                    </body>
                    </html>


Top
 Profile  
 
PostPosted: Mon Dec 18, 2017 3:15 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13564
Location: New York, NY, US
Yes, a dot character inside quotes is just a period. Outside quotes it is a concatenation operator.

There is no close double quote on this line:
Syntax: [ Download ] [ Hide ]
                    $body = "$first_name $surname ?>,

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group