Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Parse error : syntax error in PHP

    Hello,

    I'm bit new to PHP. Could anyone please tell me what's wrong in the below code snippet?

    1. <?php
    2. $_page = null;
    3. include(MODS_DIRECTORY."/client.php");
    4. $auth_url = "http://localhost/server.php";
    5. $data = file_get_contents();
    6. $result = json_decode($result);
    7. if($result['valid'] != true){
    8. die("Invalid Key. Script Stopped!")
    9. }
    10. ?>


    I'm getting Syntax Parse error: Unexpected '}' at line no.9

    Thanks!

  • #2
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    The die statement on line 8 has no semi-colon after it.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Interestingly enough, and I don't suggest you do this for both readability and code adding reasons, if you omit the braces and use single instruction evaluation on the if block, your code would have worked fine. In PHP, you don't require the semi-colon on the very last instruction in a script. I personally feel this is a bug in the core that was passed off as a feature though, so you really shouldn't rely on that. Just thought I'd make a mention of it.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •