954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

try-catch parse error

Hi all. I'm trying to move someone else's app onto a different server (and debug it in the process). Among the onslaught of bugs to squash, theres one I just cant get my head around... I get a parse error on try-catch, and I have no idea why. I've isolated the problem code and tested it on a virtual server -- no problems. I'm sure its server/ini settings that don't fit. Any ideas?

Parse error: syntax error, unexpected '{' in ~/includes/generate_pdf.php on line 15


Line 15 is 'try {'

try {
$pdf = Zend_Pdf::load(dirname(__FILE__)."/bla.pdf");
}
catch (Zend_Pdf_Exception $e) {
throw $e;
}


I've commented out all code surrounding this section and I still get the same error. Am I being a noob here?

rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 

It may be because of un paired { or }.
Post complete code.

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

I literally have removed everything. any try-catch statement and PHP rejects it with the same error. weirdest thing Ive ever seen.

rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 

What version of php are you using on the new server?

What version did it run on before?

madCoder
Junior Poster
145 posts since Feb 2010
Reputation Points: 21
Solved Threads: 37
 

Check the opening and closing of bracket '{}'. And make sure that all are properly nested.

It may due to the error above the line 15. It is helpful if you post the complete codes.

Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
 
What version of php are you using on the new server?

yep, thats what the problem was. try-catch was introduced as of php 5, and the new server was running an older version of php.

cheers madCoder (and everyone else)

rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: