Forum Moderators: coopster

Message Too Old, No Replies

What am I missing?

Nothing shows, not even error messages.

         

g1smd

9:32 pm on Aug 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm working on a largish piece of code and all I get in the browser is a blank screen.

I added
error_reporting(E_ALL);
ini_set('display_errors', '1');

but I still get no output and no errors.

If I write one line of code with a deliberate error, I see a message about syntax errors.

As soon as I add some of the functions from the new long code, I just get a blank screen.

How to find the syntax errors when there's no output and no error messages?

Even "print"ing variables and using "var dump" shows nothing (unless it's on the very simple one or two line test code).

swa66

11:40 pm on Aug 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any calls to ob_start ?

Ref: [php.net...]

g1smd

11:55 pm on Aug 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No. This is just a few functions with preg_match, str_replace and preg_replace and a few arrays.

brotherhood of LAN

12:15 am on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



have you tried "echo 1;" near the top to see if anything is produced? If so, just keep echoing numbers until you can see where the script falls.

If there is still no output, try commenting out the lower pieces of code.

Not the best way to debug but should work.

lucy24

1:24 am on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can everyone assume you've done the routine checks for invisible errors? nbsp or tab for space, line-end space where there isn't supposed to be one, that kind of thing. All brackets match, nothing interlocking, all nests come out even? In short, the whole category of "D'oh!" errors that are so obvious you don't even think of them.

g1smd

1:34 am on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah. As far as I can see I've done all that.

And
print "hello";
on the very first line yields nothing if I add the other code after it.

I've now spent over 20 hours commenting bits of code out and still not an error message in sight.

omoutop

5:52 am on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



remove all functions/includes
run the code from a single function in your page
try to debug line by line
make sure you echo/print/var_dump something and that your function doesn't "return" an empty string
Have your full error reporting (E_ALL) in your php and htaccess file

other than that i know not any other way to debug

g1smd

10:38 am on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So far, one missing bracket in a preg_match and a missing semi-colon.

That's brought 7 out of 8 functions to life. When I add the last one, it's a complete blank out, everything reverts to blank screen and no error messages.

Never had to add code one line at a time before.

g1smd

12:17 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Dang! An extra bracket inside one function and a missing bracket inside another.

lucy24

10:13 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: twiddling thumbs and whistling idly ::

g1smd

10:19 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



However, looking at the code as closely as I have over the last couple of days, I identified several potential bugs very early on and already fixed them along the way. Once the syntax was correct the whole thing worked exactly right, first time. I still have no idea why the simplest of syntax errors results in a completely blank screen and no error messages though. I've never spent so much time tracking down such simple errors.

swa66

10:26 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you check the apache error log ? I usually keep a tail -f on that one ... and try to run the php from the command line as long as it's not too interactive -> gives you syntax errors that are IMHO easier to deal with.

g1smd

10:38 pm on Aug 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One of those rare occasions with no log access, and couldn't override from within htaccess - and I did waste an hour or more trying to do that.

lucy24

2:15 am on Aug 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I still have no idea why the simplest of syntax errors results in a completely blank screen

You get the same thing in javascript. It just sits there poker-faced "Neener-neener, I'm not going to give you the tiniest trace of an iota of a hint about what you did wrong or where you did it. I'll just quietly refuse to execute." So you comment-out the entire content of every single function, cancel your plans for the weekend...

When I'm trying to make sense of someone else's code, the very first thing I do is add a line break before and/or after every single bracket. And then start indenting packages. That's where you get the "Oh, oops, these two elements were supposed to be parallel."

g1smd

1:12 pm on Aug 11, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I thought I had done that.

However there was a disconnect between thinking and doing.