Replies To: PHP Syntax Error..Simple but I cannot find it

Re: PHP Syntax Error..Simple but I cannot find it

Posted 29 October 2011 - 07:18 AM

Perhaps if you had some sanity in your code indentation and formatting, it might be obvious! What the hell are you using to edit your code? Here's what it SHOULD look like (at least one minor variation):

Re: PHP Syntax Error..Simple but I cannot find it

Posted 29 October 2011 - 09:46 AM

I have worked it 3-5 different ways, this code is in a large repository for Moodle developers. It is for an older version of the platform. It, at one time, was deployed in probably 10000 installations world wide. Anyway thanks I will ask others...Have you ever used a FOREACH loop before?

Re: PHP Syntax Error..Simple but I cannot find it

Posted 29 October 2011 - 10:16 AM

Oh, sorry. I saw the missing brace and thought that was your only problem. As Jack has already pointed out, you can't put an 'else' with anything but an 'if'. Without giving you line numbers I don't see how it could be any clearer.

Re: PHP Syntax Error..Simple but I cannot find it

Posted 29 October 2011 - 10:23 AM

Here is a version..notice the IF and ELSE are connected....

error still - unexpected T_ELSE

I am aware there is a structural mistake..can you find it? I can paste all the versions where the if-else are re-written etc...but I still get the same error. And the foreach seems closed ... and I cannot find any lines that have been incorrectly terminated.