Jump to content
The Uniform Server Community
poirot

PHP showing blank pages

Recommended Posts

I tried both Production and Development versions of php.ini, but when there are any errors in the php file the server will display a totally blank page, which is extremely counter productive. Why not just show the errors? ;)

 

Instead of showing this:

 

 

Show this:

 

Parse error: syntax error, unexpected ',' in W:\www\file.php on line 8

 

(running Uniserver 5.5)

 

EDIT: This problem (I don't know if it's intended "feature") occurs with all versions since 4.4, I had to use 3.5 to avoid this annoyance.

Share this post


Link to post
Share on other sites

I think the answer I just got for my problem might be helpful to you. I don't know how to link to it so I'll repeat the answer (from Ric) here:

--------------------------------

There are two configuration files for PHP production and development.

 

For security reasons Uniform Server defaults to production and error reporting to screen is disable.

 

To check which file you are using, from UniTray run “Server Status”

A script will run, fourth line down shows which file is switch in.

 

For error reporting you need to use the development file.

From UniTray select “Advanced”

From sub-menu run the third item from bottom “php.ini switch to development”

Restart servers to allow new configuration to be picked up.

 

Errors will be displayed to screen

Additional errors are found in file UniServer\usr\local\apache2\logs\error.log

This file is accessible from UniTray “Server information and logs”

 

This answer was from Ric

----------------------------------------

Hope this helps,

Retsel

Share this post


Link to post
Share on other sites

Put this is your index.php (main file) of your website.

 

<?php
ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'Off');
ini_set('log_errors', 'on');
ini_set('error_log', 'error.txt');
if(filesize('error.txt') > 10485760)
ini_set('log_errors', 'off');
?>

 

With this script, users who surf the website will not see the error, however, it will be saved in a text document, waiting for you to check it out and lets you see and fix the errors. Even those you haven't found yourself, but other users have found. Will be written in the text document. Very handy. :angry:

 

Create a file named error.txt in same dir as index.php and you're good to go :angry:

Share this post


Link to post
Share on other sites

I have the same problem, my pages no loads, I tried meny things.

 

I put this code and no worked.

 

<html>

 

<head>

 

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Teste</title>

</head>

 

<body>

<? echo "Hellow world"; ?>

 

<?php

echo "Este servidor fornece suporte ao PHP";

?>

<?php

ini_set('error_reporting', E_ALL | E_STRICT);

ini_set('display_errors', 'Off');

ini_set('log_errors', 'on');

ini_set('error_log', 'error.txt');

if(filesize('error.txt') > 10485760)

ini_set('log_errors', 'off');

?>

</body>

 

</html>

But, if I would put parted in file with php extension, works perfctly.

I don't understand what is happening.

Share this post


Link to post
Share on other sites

OK Lets take a step back!

I assume you have switched to development mode. :)

 

Reduce your test code to this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Teste</title>
</head>
<body>
<? echo "Hellow world"; ?>
<?php
echo "Este servidor fornece suporte ao PHP";
?>
</body>
</html>

Save the file as test.htm or test.html to folder UniServer\www

 

Run servers and type http://localhost/test.htm or http://localhost/test.html

 

Yep! A blank page. The server is not configured to pass files with extensions .htm or .html to the PHP processor.

 

Hence no matter what you do you will never see an error message! :angry:

 

1] Now rename your file to test.php

Type http://localhost/test.php

 

Result as shown: “Este servidor fornece suporte ao PHP”

 

2] There is no “ Hellow world” as expected. This is because short tags are not enabled :)

Hence change this:

echo "Hellow world"; ?>

To

<?php echo "Hello world"; ?> B)

 

3] If you do want to pass .htm and .html files to the PHP processor

Quick fix:

Edit file UniServer\www\.htaccess

Add the following line to end of file

AddType application/x-httpd-php .html .htm

 

4]Alternatively edit Apache config

\UniServer\usr\local\apache2\conf\httpd.conf

Locate this line:

AddType application/x-httpd-php .phtml .php3 .php

And add the extensions

AddType application/x-httpd-php .phtml .php3 .php .html .htm

 

All .htm and .html pages are passed regardless whether they contain no php. It is a hit on processor time. Hey! Your server, if that’s what you want, no problem B)

 

All the best

Ric :)

Share this post


Link to post
Share on other sites

I am a new user and I am having this problem with blank pages as well.

 

I have read all of the above and I have put UniServer into development mode and tried the test code supplied by Ric above (Thanks Ric) both named as test.htm and test.php.

I get a blank page with every time.

 

I checked C:\UniformServer\UniServer\usr\local\apache2\logs

I have checked both the error.log and access.log but do not show any errors for when I access the test.htm or test.php or any of the other short php files I have created. If I try to access a page in the directory using an incorrect file name I get a 404 error message but if I type the correct file name I get no error message, my browser shows the name fo the file and I get a blank page.

 

I should add. I have been using Uniform Servers for several days and have several Drupal sites installed under it working A-OK. It is just now that I have begun to try to write some of my own PHP that I hit this snag. Drupal sites still work just fine.

 

Any other ideas on how to get php files to display correctly?

 

Thanks,

 

Steve

Share this post


Link to post
Share on other sites

I've been experimenting and had partial success - Some non blank screens - as follows:

 

This code

<?php

print "Hello Web!";

?>

gets me a page that says - Hello Web!

 

This code

<?php

phpinfo();

?>

gets me a page the PHP Info page as expected.

 

This code

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Test</title>

</head>

<body>

<? echo "Hello world";?>

<?php

print "Este servidor fornece suporte ao PHP";

?>

</body>

</html>

gets me a page that is completely blank.

 

and

 

This code

<html>

<head>

<title>Listing 3.2 A PHP script including HTML</title>

</head>

<body>

<b>

<?php

print "hello world";

?>

</b>

</body>

</html>

 

gets me a page that is completely blank

 

I sure hope somebody will be able to help us out with this

 

Thanks

 

Steve

Share this post


Link to post
Share on other sites

Well - I feel like an idiot but I am no longer getting blank pages so I thought I'd better admit my stupidity to save others time and trouble.

 

When some of my php scripts started working I got suspicious that maybe I was saving them incorrectly as formatted files since I was using Wordpad and Notepad as editors. Sure enough that was the problem.

Share this post


Link to post
Share on other sites

Welcome to the master class – Of idiots! :)

I checked your code and could not fault it.

 

That little gem had not crossed my mind! :angry:

Thanks for the post. B)

All the best

Ric B)

 

Yep! I was looking for something I missed. :)

Share this post


Link to post
Share on other sites

Thanks a lot for this topic.

It helped to solve my issue of the blank page.

Unfortunately the new php is issuing awful "notices" before rendering the page. Any way, I disabled development and I will check later.

Best regards

joejac

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...