Jump to content

PHP files not displaying in browser


fatal_banana

Recommended Posts

I'm having a client side issue that's probably a server side issue. A test php file of phpinfo will properly display in browser when I navigate to that page. However, when I try to access any other php file, the page is completely blank. Here is one of the php files that won't display anything:


<?php
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";

$mysqli = new mysqli("127.0.0.1", "user", "password", "database", 3306);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

echo $mysqli->host_info . "\n";
?>

its labeled test2.php and is in the application's root directory. I get a blank page in Firefox and Internal Server Error 500 from Internet Explorer (which is almost never used).
I'm not entirely sure where to start with this and any other posts I've found about this were no help.

 

Also, I'm pretty new to php and what not, so be gentle :happy-04:

Link to comment
Share on other sites

if the php.ini that you are changing is the one that php is using, and you have confirmed that the settings took effect in the phpinfo() output, any php errors should be displayed in the browser when the .php page is output. in some cases, the php error messages are inside of html tags/form elements and are only visible in the 'view source' of the page in your browser.

Link to comment
Share on other sites

This is from my phpinfo() page. I dont see anything disabled that seems suspect, but I'm very inexperienced.

 

Debug Build no Thread Safety disabled Zend Signal Handling disabled Zend Memory Manager enabled Zend Multibyte Support disabled IPv6 Support enabled DTrace Support disabled
Link to comment
Share on other sites

Nope. No html markups in the file. It's file name is test2.php and all of the code that is in that file is exactly as aforementioned. It's saved in the normal spot /var/www/html. I'm using centos 7 if that makes a difference.

 

exact source in browser is

<html>

<header>

</header>

<body>

</body>

</html>

Link to comment
Share on other sites

about the only remaining thing that could be causing this symptom, is if there's a file naming (capitalization matters on a case-sensitive operating system) or permission problem and the web server cannot find or access your file, combined with something preventing a http 404 or related error from being output.

 

check the web server access and error logs to see if there are any errors that correspond to you requesting the file in your browser.

 

this also raises a question, what url did you use in your browser when you requested the page containing the php code with the phpinfo(); statement in it? it should have been something like http://localhost/yourfile.php

 

if nothing else, start over with a new file, with just <?php echo 'something here'; ?> in it, save it to the document root folder, and enter the url, http://localhost/your_filename_here.php in the browser and see what you get.

 

short-answer - this is not that difficult. if you have one .php file that works, but others give no output from the php code and no php errors, there's something you are doing differently between the files that isn't correct.

Link to comment
Share on other sites

we only see the code you post. it is not missing a ; and does not throw a php syntax error due to that.

 

if you set the php error_reporting/display_errors setting as i suggested, in the php.ini  file, and confirmed that the actual settings got changed to those values, you would have been getting a php syntax error at the missing ;

 

 

do you have php's error_reporting set to E_ALL and display_errors set to ON in the php.ini on your development system so that php would help you by reporting and displaying all the errors that it detects? you will save a ton of time.

Link to comment
Share on other sites

  • 2 weeks later...

One more things to try: before the first <?php place just the word STARTING. Then at the very end of the file (after the last ?>, place the word ENDING.

 

Load the file in your browser. Do you see STARTING and ENDING? If not your server isn't sending the file to the browser. If you do see them, you must have some kind do of php issue.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.