PHP file makes webpage go blank - php

I'm a novice in PHP and recently changed the home page of my website from index.html to index.php. When I changed the file to PHP, it would display a white blank page. Changing the file back to HTML would restore the page back to normal.
Anybody know why the page goes blank when the extension is changed to PHP, and how I can fix it?

Some ideas:
If there's some PHP in the file there might be errors in it, see if you can check your webserver error log
There might be a .htaccess file that's hard coded to redirect to the html filename, see if you have a .htaccess file in that directory.
The webserver might be configured to not read php files, see if you can check your webserver error log

Related

If I rename an index.html to index.php, the CSS style disappears

Yesterday I discovered a website called Too Plate:
https://www.tooplate.com/about
It has free HTML templates, and all they are very beautiful.
I had the idea to turn the theme that I chose to PHP, so, I just renamed the file index.html to: index.php
But, when I open it using a brwser, all the style is gone... As if the template could not find the CSS file... But I just renamed the file, I did'nt change anything inside the code (I only added the "" tags a the beginning...)
This is the template:
https://www.tooplate.com/view/2122-nano-folio
How can I fix this, please?
Once you add the PHP extension it handles the file as a PHP script, which is a server-side language that's get executed on the server before loading the page, so to view ant PHP file you have to have a server running the PHP code, but HTML runs on any browser.
So what happened was that because you changed the extension the browser treated it as a PHP script and cant Execute the script because it's not a server.
you must need to run the code in server eg: local servr xampp or wampp then only your php code work try this
https://felbdogg.com/test2/index.php
code works fine... I'm not sure what you changed but I uploaded it to my server and works the same as what I downloaded.
If your opening it on your computer without a server it will not load. XAMPP is free and works great for testing.

Drupal not rendering page content

I'm trying to create a full backup of cyclekids.org. I've backed up all the files, dumped the database, and restored it on another machine (beta.cyclekids.org). However, Drupal doesn't seem to be rendering any page content on the backed-up site. Even pages that 404 on the regular site display the same mostly-blank template with a smattering of content.
What are likely culprits for this (e.g. misdirected theme file or broken config)?
There can be multiple reasons:
First, upload some simple php file containing only php info function (http://php.net/manual/en/function.phpinfo.php), call it and see is everything ok there with the server. I.e. do you have PHP enabled at all. Don't forget to delete that file when it starts working.
If you get php info output that means that php is working. So next problem could be that because of different server settings you are getting php error, but errors are not displayed.
Try finding in your control panel where php settings are and turn off on page error reports.
If you can't find it in control panel, try enabling error reporting from the code: add
error_reporting(E_ALL);
as first function in index.php file in site root.
Check how much memory PHP has available. Upload some php info file to working site and compare difference in their output.

Unexpected Rewrite

On localhost, in one of my folders, files are accessible like http://localhost/folder/map instead of http://localhost/folder/map.php. It's probably because of something wrong with Apache's configuration but I'm stuck here and nothing comes to my mind.
If you have a file called index.php or index.html in your http://localhost/folder/map folder, Apache will run that file when you just enter the directory name as a browser url.
This is what makes http://localhost run a page rather than just showing you a directory listing, or show a blank page.
This is probably the reason that you see a valid page when just keying in the http://localhost/folder/map url.

Wamp Server showing blank page for nested directory

This link
http://localhost/
works fine.
This link doesn't work
http://localhost/shlingy/
directory location
C:\wamp\www\shlingy\index.html
Does anybody know why this link does not work?
Check whether there is a .htaccess file in www or www/shlingy directory or not. If there is, rename or remove it. Probably a rewrite rule in that file is causing the problem.
Also, make a index.html file in the www/shlingy directory which will be displayed when you access the shlingy.
It was a mistake on my end that i call a constructor of PHP file at the start page but that file contain an error. Its annoying that server just show blank page instead of error Massagining

php code displaying on web page instead of working behind the scene

I have an index.html in my wampserver www directory. On this html, there is a link for a user to upload file. When I hit the link, I select files to upload but instead of the uploadmanager.php which i have tested in my eclipse debugg environment to work, it displays the some part of the code on the web page without doing anything thing. This is not what I expect. Can someone please tell me what is wrong? Thank you.
sound like you are using php-short-open-tags (<? instead of <?php) without enabling this in your php.ini. change your php.ini or use the standart open-tags to solve this.
Are you sure you enabled PHP in WAMP?
Try creating a new uploadmanager.php file directly in wamp/www (or whatever subdirectory) and paste the code from your tested uploadmanager script into the new file. Then try to run it in WAMP.
I think it is a permissions problem. I copied an index.php file into a c:/wamp/www/subdirectory and it only displayed the code. Once I created a new index.php file and pasted the contents of the old file into it, it worked perfectly.
Are you posting to the uploadmanager.php page? Are you getting an error or just seeing the code? Can you post the code from the index.html page that handled the form and the part of the php code you're seeing for us to look at?
Every now and then I have Apache serving the .php as downloadable files instead processing them on the server, but only with random requests.
Some reasons, why this might happen, are
PHP misconfiguration
PHP-files in a directory without execute rights
wrong content type sent
timeout from script execution
In my situation the last bullet is the most dangerous, but luckily it seems to show up only immediately after modifying some of the .php files. I haven't tracked the problem any deeper yet, but it seems to relate some filesystem level operations (as the disk I/O is a bottleneck) and presents itself only in testing env.

Categories