Results 1 to 9 of 9

Thread: cant find out why this error appears

  1. #1
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default cant find out why this error appears

    ok so ive got the following code and it wont work... it is for facebook, but i still cant find the error. order is the code, then the error.

    Code:
    <?php
    require_once("facebook.php");
    
    $appapikey = '<hidden>';
    $appsecret = '<hidden>';
    $facebook = new Facebook($appapikey, $appsecret);
    $user = $facebook->require_login();
    
    //[todo: change the following url to your callback url]
    $appcallbackurl = 'http://michael.hungerford.us/fb.prayer.list/';  
    
    //catch the exception that gets thrown if the cookie has an invalid session_key in it
    try {
      if (!$facebook->api_client->users_isAppAdded()) {
        $facebook->redirect($facebook->get_add_url());
      }
    } catch (Exception $ex) {
      //this will clear cookies for your application and redirect them to a login prompt
      $facebook->set_user(null, null);
      $facebook->redirect($appcallbackurl);
    }
    ?>
    and it returns the error:

    Parse error: parse error, unexpected '{' in /homepages/37/d91075885/htdocs/hungerford/michael/fb.prayer.list/appinclude.php on line 13

    i cant figure out why i get this error. if it had somehting to do with the required file, it would say an earlier line... so can u help me?
    Last edited by motormichael12; 06-03-2007 at 12:55 AM.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Not sure what it could be, but here is something that you could try. Try changing the comments from this:

    Code:
    //This is your comment
    to this:

    Code:
    /* This is your comment */
    Hopefully that will work, and hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    ive tried completly removing all the comments... no luck.

  4. #4
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    hmm oh! http://us.php.net/try says "PHP 5" and i have 4.4.7! thats funny cuz this was made by someone for php 4...

  5. #5
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    I'm not exactly sure what you're trying to do with, "try" and "catch". They have to be functions, and I see several problems with that: for one, you do not say function before them and two, if you're calling the function already set in facebook.php, you wouldn't do so with brackets, but with parenthesis.

    If I'm wrong, I'm going to look stupid. But that's all I could see that made me wonder.

    ex:
    PHP Code:
    function try() { 
     if (!
    $facebook->api_client->users_isAppAdded()) {
        
    $facebook->redirect($facebook->get_add_url());
      }

    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  6. #6
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    well i dont think its stupid, i thought maybe it was like that too. but no its an exception. go here http://us.php.net/try

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    That's pretty much all it could be (the fact that try and catch are PHP 5+ only) that is causing the error. You could try making it a function, but not sure if that will help.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    try jumped out at me too.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    The exception used is interesting to me, and I guess if you used it you know more than I about such things. I may learn a bit more about it and use it myself.

    However, I honestly don't see anything else that could be wrong.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

Bookmarks

Posting Permissions

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