473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

php try / catch gives syntax error

When I use the try / catch in a program I consistently get a syntax error pointing at the curly bracket after the TRY.

Is there something in the PHP5 setup that needs to be set?

Or any suggestions as to why this happens?
Jan 29 '12 #1
4 1973
Rabbit
12,516 Expert Mod 8TB
We need to see the code.
Jan 29 '12 #2
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. require 'facebook.php';
  4.  
  5. // Create our application instance
  6. // (replace this with your appId and secret).
  7. $facebook = new Facebook(array(
  8.   'appId'  => 'YOUR_APP_ID',
  9.   'secret' => 'YOUR_APP_SECRET',
  10. ));
  11.  
  12. // Get User ID
  13. $user = $facebook->getUser();
  14.  
  15. // We may or may not have this data based 
  16. // on whether the user is logged in.
  17. // If we have a $user id here, it means we know 
  18. // the user is logged into
  19. // Facebook, but we don’t know if the access token is valid. An access
  20. // token is invalid if the user logged out of Facebook.
  21.  
  22. if ($user) {
  23.   try {
  24.     // Proceed knowing you have a logged in user who's authenticated.
  25.     $user_profile = $facebook->api('/me');
  26.   } catch (FacebookApiException $e) {
  27.     error_log($e);
  28.     $user = null;
  29.   }
  30. }
  31.  
  32. // Login or logout url will be needed depending on current user state.
  33. if ($user) {
  34.   $logoutUrl = $facebook->getLogoutUrl();
  35. } else {
  36.   $loginUrl = $facebook->getLoginUrl();
  37. }
  38.  
  39. // This call will always work since we are fetching public data.
  40. $naitik = $facebook->api('/naitik');
  41.  
  42. ?>
Jan 29 '12 #3
I am using php 5.2.17
Jan 30 '12 #4
Rabbit
12,516 Expert Mod 8TB
I don't see anything obviously wrong with the code. I would double check the PHP version.
Jan 30 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Justin Case | last post by:
I have a Perl app that stores pictures in a blob. Now I want to load a thumbnail version of the picture into another blob column, but the update fails with a syntax error. I'm able to insert the...
6
by: Euripides J. Sellountos | last post by:
Hello kind people. I hope you can you help me with the following problem. The following snippet fails to compile with g++. (It compiles fine with other compilers.) All I want to do is to throw...
1
by: Ronny Sigo | last post by:
Hello all, I have made a form containing a combox which must look up values (names) in a table. It works fine until the moment I try to put in a name containg an apostrophe. (e.g. d'Haen). At this...
5
by: Berend | last post by:
when I try to write to a database I get a syntax error I made the code a simple as possible bur also the VS generated code gives the same error. WHY? private void button1_Click(object sender,...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
4
by: rukkie | last post by:
Hi, I have some problems with a PHP reference in a <SCRIPTtag, but only with the Internet Explorer, which gives a "Error on page" message in the Status Bar. The code is as follows : <script>...
1
by: basswhizz | last post by:
Hi guys im having trouble with somethings else now can you help out thanks!! Im getting this error message Parse error: syntax error, unexpected $end Here's my code cheers!!] <?php //...
4
by: nickyeng | last post by:
i calling this piece of java code in jsp : List<Customer> list = Customer.listby_page(currentRs); ... ... then it gives me the following error:
9
by: Suresh Jeevanandam | last post by:
Hello everybody! I am using g++ 3.2.3. When I try to do try{} catch{} it works fine if I catch(int a). But if I do catch(SomeException e) it raises syntax errors. Any guess whats wrong? ...
3
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For i =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.