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?

Recommended Answers

All 5 Replies

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

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

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

What version did it run on before?

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.

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.