Sunday, March 1, 2020

PHP Troubleshooting When Page Loads All White

PHP Troubleshooting When Page Loads All White You upload your PHP web page and go to view it. Instead of seeing what you expected, you see nothing. A blank screen (often white), no data, no error, no title, nothing. You view the source ... its blank. What happened? Missing Code The most common reason for a blank page  is that the script is missing a character. If you left out a   or } or ; somewhere, your PHP wont work. You dont get an error; you just get a blank screen. There is nothing more frustrating than looking through thousands of lines of code for the one missing semicolon that is messing the whole thing up. What can be done to correct and prevent this from happening? Turn on PHP Error Reporting. You can learn a lot about what is going wrong from the error messages PHP gives you. If you arent currently getting error messages, you should  turn on PHP error reporting.Test your code often. If you  test each piece as you add it, then when you encounter a problem, you know the specific section to troubleshoot. Itll be in whatever you just added or changed.Try a color-coded editor. A lot of PHP editors- even free ones- color code your PHP as you enter it. This helps you pick out lines that dont end  because youll have large chunks of code in the same color. Its non-intrusive for programmers who prefer to code with no bells and whistles but helpful when troubleshooting.Comment it out. One way to isolate the problem is to comment out large chunks of your code. Start at the top  and comment out all but the first couple of lines in a large block. Then echo () a test message for the section. If it echoes fine, the problem is in a section further dow n in the code. Move the start of your comment and your test echo downward as you work through your document, until you find the problem. If Your Site Uses Loops If you use loops in your code,  it could be that your page is stuck in a loop that never stops loading. You may have forgotten  to add  Ã‚  to the counter at the end of a loop, so the loop continues to run forever. You may have added it to the counter but then accidentally overwritten it at the start of the next loop, so you never gain any ground. One way to help you spot this is to  echo() the current counter number or other useful information at the beginning of each cycle. This way you might get a better idea of where the loop is tripping up. If Your Site Doesnt Use Loops Check that any HTML or Java you use on your page isnt causing a problem  and that any  included pages  are without error.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.