Log in

View Full Version : cant find out why this error appears



motormichael12
06-03-2007, 12:50 AM
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.



<?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?

thetestingsite
06-03-2007, 12:55 AM
Not sure what it could be, but here is something that you could try. Try changing the comments from this:



//This is your comment

to this:



/* This is your comment */


Hopefully that will work, and hope this helps.

motormichael12
06-03-2007, 12:57 AM
ive tried completly removing all the comments... no luck.

motormichael12
06-03-2007, 12:59 AM
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...

alexjewell
06-03-2007, 01:05 AM
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:


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

motormichael12
06-03-2007, 01:27 AM
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

thetestingsite
06-03-2007, 01:30 AM
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.

djr33
06-03-2007, 06:16 AM
try jumped out at me too.

alexjewell
06-03-2007, 05:10 PM
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.