php script appears as a blank screen - php

I'm trying to run a php script on my website through my file manager but it just shows a white blank screen. I ran a couple of test php scripts on my file manager and runs well. The php script that runs a blank screen has been tested offline with WAMP and works fine, The php script involves connecting to a database which it does, uses simple_html_dom for web scraping and inserting to a database. Can someone please help. Surely if it works offline it should work online no error messages are showing

Turn on your error reporting first :
error_reporting(E_ALL);
It might be occurring because you have switched off the error_reporting and the connection is not being successful.
Check if your database connection credentials are correct.
If the problem still exists, refer to this page :
PHP Blank Screen - Solutions

Make your error reporting on by
error_reporting(E_ALL);
Also, please check php's error log file.
Every page crash is printed there.
Generally, in php folders of WAMP, XAMPP.
For XAMPP in Windows, the file location is:
xampp\php\logs\php_error_log

Related

AMPPS not displaying errors?

I looked PHP.ini files but error mode is on there?
But when there is error in my code I cannot see php showing error??
I use local host called AMPPS.
And whenever there is error i see blank page like if i use:
require('something.php');
There is a blank page instead of showing fatal error or warnings.
I use CodeCanyon script. Can script change the error showing mode?
How can I display all there error even if it is small on as I am on development mode.
Can script change the error showing mode?
Yes, it can. For starters you can set this in your PHP file—before code like require('something.php');—to force errors to show:
error_reporting(E_ALL);
ini_set('display_errors', 1);
But that said, if errors are not displayed at all, check your Apache logs in your setup. Unclear on where in AMPPS the logs would be stored—or what your host system running AMPPS is—but there should be a log in there somewhere.

PHP website does not work, and nothing logged in the error log

I have a problem with PHP. There is an error that I have never encountered before. The home.php, which is the main page of my site, cannot be viewed. And there is nothing in error log. After there is an inclusion of a php page (a class that is a part of my API). Till that line the holl HTML (javascript and css inclusions) are echoed from php and successfully rendered in browser, but after the php kind of stops suddenly. When I delete that line(php page inclusion line), website works, but before, this inclusion didn't make any problem for me. I removed the code parts which after them I encountered this problem, but nothing works.
I am using Apache2, PHP5 with Ubuntu 11.10.
Any help will be appreciated, thanks in advance.
My first hints would be to check the following:
In your script set ini_set('display_errors', '1'); and error_reporting(E_ALL); to display all errors.
Turn on the php error log and check it for errors.
run php -l home.php on the command line to check your php file for syntax errors.
Check Apache's error log, sometimes error messages go there.
If nothing helps use a debbugger like XDebug to see where the script terminates, or alternative insert statements like die("here"); and move them around in your code, to see which parts of your scripts are passed.
Greetings and good luck.

Is there an Easy out of the box solution to debug PHP?

I am writing a php web application and I get stuck because my script doesn't work how I would expect. Then I check the logs and I get nothing. My php.ini file is set to display all errors and log all errors. But I am not getting anything. On my mac, how can I debug PHP so I can step through the code and see what the problem is?
If you use apache then look into apache logs.

Specific php question

I am fairly new to creating websites and I have done a website that I did in a sandbox server on my personal computer, it works brilliantly, but as soon as I try to put it on my companies server to go up on the internet it doesn't work anymore. What the site does is it takes fields from an html form and then does a sql search of a database that I set up and works fine. Then after the user is done with the form they hit submit and the sql is run and results are returned to the same page. The form action="" and then the results are returned. I am not sure if the companies server has php installed, but I don't know if that would be a problem or not because the browser should still be able to display the php code. I have no problems with the html form, it is just when I hit submit that the page is returned and nothing is displayed.
Any help is welcome.
"I am not sure if the companies server has php installed, but I don't know if that would be a problem"
It is. Browsers can do nothing with PHP. Maybe you shoud register for a free hosting provider and learn the basics of hosting there.
PHP is a server-side language (i.e., it runs on the server, not the user's machine). Therefore, it must be installed on the company's server for any PHP code to execute properly. Browsers cannot interpret PHP code, and moreover PHP code is executed before the browser even receives any information (PHP: Hypertext Pre-Processor). Check that the server has PHP installed before you continue. (Also be aware of versions and features. For example, to use many new PHP features your server must be running PHP5.)
If you find that PHP is installed: Check your PHP syntax; make sure that no headers are sent after text is sent to the page; and make sure that there are no loops or anything in your code that could cause the script to continuously run without printing to the page.
Also, since your page is returned when you hit 'Submit,' but no new information is shown, make sure that there is not a problem with the MySQL configuration (e.g., incorrect password, query syntax, etc).
First you have to be sure that server has PHP installed.
make a file named phpinfo.php with this line
<?php phpinfo() ?>
and call it.
If it won't print out PHP config, you have to install PHP first.
Otherwise the problem most likely in the form of PHP tags, and you are using <? instead of <?php.
To solve, you can either change tags or set short_open_tag to on in the php.ini
According to your comment
when I hit submit that the page is returned and nothing is displayed
I am going to make an assumption that you are getting a blank page. If that is correct, then I am also going to follow that up with the assumption that PHP is installed, there is an error in your script (my guess is the database connection), and that the error is not being displayed.
Add these lines to the top of your page and post back with the result:
error_reporting(E_ALL);
ini_set('display_errors', '1');
Ya I think there is a problem in your database connection.First run your connect file whether it is showing some error or not.Plase add this line to your page:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
And please modify your php.ini file with this line:
display_errors = on

PHP ftp_connect does nothing

I've configured a couple of php codes that connects to my server with the use of ftp connect. It works perfectly when I'm testing it locally, it connects, it goes in, i can access stuff.
BUT
when I upload it online and try it there. The php code does nothing. It executes all lines before "ftp_connect" then from that line onwards, it doesn't get processed.
It doesn't show any errors, warnings, etc on screen but the code execution from the line of "ftp_connect" just stops.
What seems to be the problem?
Your host probably has error reporting turned off, try turning on error reporting with
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
at the top of your file, or check for a file called error_log in the directory of your script.

Categories