Blank Pages

From TNG_Wiki
Jump to: navigation, search

Occasionally when making changes, you might end up with a page where suddenly the page content disappears, and is completely blank. No content. No errors. Nothing.

This most often, but not always, happens after updating a TNG script or custom text file. This could be referred to as the White Screen of Death or WSOD. There are several reasons why this might occur, and therefore several possible solutions to the issue.


Whitespace at the End of File

You have a blank line after the closing ?> at the end of a php file. There should be nothing after the closing php tag.

Recommended actions

You should remove the blank lines after the php closing tag ?>


Byte order Mark

You have the UTF-8 byte order mark (BOM) in front of the <?php at the beginning of a php file. This is often caused by using Microsoft Notepad to create UTF-8 encoded files.

Recommended actions

You will need to remove the byte order mark (BOM) in front of the <?php tag. Not all editors will display the BOM.

You should use Notepad++, PSPad, TextWrangler, or another ASCII editor to save your files as UTF-8 without BOM.


Syntax errors

The typical cause of a blank page being returned after you made some changes is a php syntax error. Normally, this is a missing semi-colon ; at the end of a line. Often it is in your English/cust_text.php file but could also be in your customconfig.php file.

You might have a missing semi-colon after a php statement, a missing ending single-quote, or have double-quotes within a double-quoted variable.

It could also be caused by $text variables that contain double-quotes that are not escaped, that is preceded by a backslash, since the double-quote would terminate the $text variable and the next character is not a semi-colon.

It appears that PHP lets you get away with a missing semi-colon ; if it is the last line in a file.

This has caused two users to report problems after installing different TNG mods recently, using the Mod Manager config files.

Recommended actions

Double check your cust_text.php file for a terminating semi-colon ; especially where you just made changes or the last line of the file before the additions.

Add the missing semi-colon ; at the end of the line to terminate the php statement, or escape any double quotes included in the $text variable by using a backslash before it.

Use the PHP Syntax Check web site to find your syntax errors.

Invisible Errors for Developers

You are using a conditional include (@include) for another php file that contains syntax errors.

For example, if you previously had the Mod Manager Edit parameters within single-quotes like the Body Text for Translation mod did in TNG v8, when you clear one of the variables in Body Text for Translation in TNG V9, which does not expect the string variables to be within single-quotes, it results in the following blank screen in the Media display

Blank page syntax error in conditional included file.png

because the Mod Manager Edit updated the variables as shown below which result in syntax errors

  $image_viewer = ''scan''scan''scan''scan'';
  $body_text1 = ''scan''scan''scan''scan'';
  $body_text2 = ''funeral''funeral''funeral''funeral'';
  $body_text3 = ''certificate''certificate''certificate''certificate'';
  $body_text4 = ''histories''histories'';

Recommended actions

Remove the conditional (@) in front of the include and debug the included script, or include the code directly into the php file until you have debugged the syntax.

Duplicate Functions

If a function is defined twice it will also result in a blank page, when error reporting is suppressed and the function is within a conditional include. For example, a function was added to customconfig.php by a mod, which resulted in 3 Admin scripts returning a blank page because the customconfig.php file was included twice.

If you add functions to customconfig.php it is not necessary to include the file, since it is already included by the TNG begin.php script.

Recommended actions

Remove the

1     include($subroot."config.php");

from your new script.

Output Buffering

Your web server is buffering output so you do not get to see intermediate messages. If output buffering is turned on, like in a WampServer default installation, you might not see the output of a script until it is done running.

Recommended actions

In Wamp Server, you should be able to click the PHP Settings and uncheck the Output Buffering and re-start the Apache Services.

On your hosting service, you might try overriding the php.ini file, or you may need to override it in a .htaccess file.

Some of this information was extracted from the following Drupal page

Related Links

Coding_Rules

PHP Syntax Check