#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7

    Question Syntax error, unexpected "


    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:

    PHP Code:
    $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 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="<?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();
                        }
  2. #2
  3. Maddening Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,492
    Rep Power
    9645
    I count no fewer than five critical mistakes in your code.

    Please stop programming with PHP. Get a job in retail. Or food service. Or something else suitable for a grade schooler.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Originally Posted by requinix
    I count no fewer than five critical mistakes in your code.

    Please stop programming with PHP. Get a job in retail. Or food service. Or something else suitable for a grade schooler.
    Oh! So, where do you spot the mistakes, may I ask ?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,386
    Rep Power
    631
    You might try learning PHP so you can find the trivial ones yourself. Just a suggestion.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Originally Posted by gw1500se
    You might try learning PHP so you can find the trivial ones yourself. Just a suggestion.
    I am trying to learn. Forget double quick what I learn at this age.
    I ain't a school kid, like Requinix thinks or sarcasts.
    Does not fit a mod to behave like that. Popping out of no where all of a sudden out of the blue like a maddening mod.
    Look what text around his Username. It spells it all.

    PS - I know requinix would say I used the php opening & closing tag unnecesarily. I did not have them originally. Just added them tonight to see if the error goes away but it did not and I did not bother removing them. I guess, after hearing this, Requinix would see me kindly.
    Last edited by UniqueIdeaMan; December 17th, 2017 at 11:21 AM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,386
    Rep Power
    631
    Originally Posted by UniqueIdeaMan
    I am trying to learn.

    "Trying to learn" implies not repeating the same mistakes and asking for help with the same errors over and over. It also implies an effort to find your own mistakes based on reading and understanding error messages, previous answers here and using the documentation. Your questions here are evidence you do none of that.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Originally Posted by gw1500se
    "Trying to learn" implies not repeating the same mistakes and asking for help with the same errors over and over. It also implies an effort to find your own mistakes based on reading and understanding error messages, previous answers here and using the documentation. Your questions here are evidence you do none of that.
    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; December 17th, 2017 at 12:23 PM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Originally Posted by requinix
    I count no fewer than five critical mistakes in your code.

    Please stop programming with PHP. Get a job in retail. Or food service. Or something else suitable for a grade schooler.
    Is that your Christmas Wish or is your bad advice a Christmas Gift to me ? Well, I got to accept this Gift a gift from Scrooge then I'm afraid. Dear me!
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    YEEEHA!

    I solved it!
    Look:

    PHP Code:
                        $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 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>"

    How did I solve it ? By reading this post:
    The Concatenation Puzzle
    I still got to read his next post that comes after it and I believe I will learn a lot from it! Now, Requinix, MOD! Why couldn't you have done something like him rather than give me a stingy Christmas Gift (bad advice to quit php!) ?
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,386
    Rep Power
    631
    You didn't all the other times you got syntax errors misusing double quotes. I wonder what was different this time.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Originally Posted by gw1500se
    You didn't all the other times you got syntax errors misusing double quotes. I wonder what was different this time.
    I learnt concatenation is not needed inside dbl quotes. Only sngl quotes.
    Afterall, concatenation is for joining 2 strings. And strings come inside sngl quotes and not dble. So, it should have been obvious to me that concatenation was not needed inside dbl quotes. In other words, there was no need to join $fistname and $surname inside a dbl quote with a concatenator. That should have been obvious to me. But, it was not. And do you know why ? Due to less practice! Remember, you learn the formulas in school but you need to go on work experience to gain the practice or real world experience. I'm lacking the practice or real world experience. And that is why, easily forget what I learn. What formula I learn. Because, there is no real practice. And that is why I choose projects like this one to build membership acc site or a searchengine or a web automator (auto link poster), etc. just to gain the real world work experience.
    Don't worry, you will soon come around. You will start liking me in the end. You have already started. Lol!
    I'll make another move ...
    I'm guessing you are 42-55. (Starting a game of some sort here. Let us see if we can brain storm a guessing game here. Can be my next project).
    Ok then, you're 35. Lol!
    You guess now. Lol!

    PS - I will be dealing with this script tomorrow so stay tuned:
    https://stackoverflow.com/questions/...in-other-words
    Might open a new thread.

    PPS - I fixed my code and no errors by fixing one thing in my code while Requinix said he can see 5 things wrong. I wonder what 4 things else he saw! Can you see the remaining 4 ?

    EDIT: Seems like I already opened a thread on banned words already! Oh well, will continue from there:
    Banned Words Filter
    Last edited by UniqueIdeaMan; December 18th, 2017 at 08:30 AM.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    402
    Rep Power
    7
    Requinix,

    What other 4 things you a me doing major incorrect ? If I'm doing these other 4 incorrect then ho come I getting no errors ? Beats me.

IMN logo majestic logo threadwatch logo seochat tools logo