Page 1 of 1

Detecting syntax errors inside php function

Posted: Wed Feb 18, 2009 2:18 am
by ogosensedan
Hello,

I just spent at least half an hour debugging a simple syntax error:

if(isset($_POST['firstname'])) $mailbody = $mailbody . "First Name: " . $_POST['firstname'];

The yello marked dot was forgotten (it's almost invisible, i'm sorry).

The problem is that this code was part of a php function that is in a file that's part of Joomla component, so once it happened (syn error), all I got as a result was an empty page.

I know this might sound silly for people that know the solution, but I'm wondering hwo to track this kind of errors. Is there a solution?

Best,
Dan

Re: Detecting syntax errors inside php function

Posted: Wed Feb 18, 2009 3:10 am
by requinix
Enable display_errors. On a production environment this can be a bad thing, especially for newbie coders. You introduce an error, people will see it. If a bad person sees it and it's a certain type of error then you can have problems - beyond just buggy PHP code.

It's a php.ini setting. Enable that on your test system, do your work on that, and when it works correctly you copy files.

Re: Detecting syntax errors inside php function

Posted: Wed Feb 18, 2009 3:14 am
by ogosensedan
Thank you, I will.