I'm administering a system used by around 100 users. Everything is working fine except for one user. When that user logs in, the source will only output about 70 lines og html and then just stop executing. PHP show no errors whatsoever, and nothing is shown in the error log. Errors is enabled in the script.
If i remove some lines, in the html, it will execute more PHP, but then still stop at about 70 lines in the source code.
This, as I said, only happens for one user.
Does anyone have an idea about what could be going wrong here?
if error is not displaying it means the error display or error reporting is off in php.ini you can turn it on by the following php functions
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
?>
place above functions in the starting of your file and it will output error if any occurs.
Related
This is my error setting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL|E_PARSE);
Now I write this test code:
helloooooo;
And It shows me:
Use of undefined constant helloooooo ...
So far so good.
Now I remove the semicolon from end of my so-called code:
helloooooo
Shows nothing. It shows a white page.
In my experience whenever I see a white page there is a syntax error so I look for a typo.
The question is why doesn't PHP help in this case?
Someone said :
Syntax checking is done before executing any code. So it can't execute
the ini_set() functions if there's a syntax error.
How about PHP interpreter applies settings first then executes the rest of code?
JavaScript interpreter can detect the same error in runtime.
Just try this:
<script>
helloooooo
</script>
Now go to Firefox => Tools=> WebDeveloper => WebConsole
ReferenceError: helloooooo is not defined
PHP's default error reporting mechanism (might) suppress error output. If you're trying to turn it on at runtime using the error_reporting function, then PHP will first have to successfully parse the file, then execute it to set that new desired error reporting level. That fails when there are syntax errors, because then PHP can't successfully parse and execute the file to change the error reporting level. The syntax error is getting suppressed because… well… it couldn't change the error reporting level yet.
Javascript doesn't have that, it outputs any and all errors it encounters.
The reason PHP likes to suppress errors is because its running on the server, and internal server debug details shouldn't be shown on public web pages. In Javascript that is moot, since it's running in the browser anyway, and the errors are reported to the console, which regular users don't see. Moreover, PHP does log all errors to a log file, so the same way you go looking for errors in Javascript, you could explicitly go looking for them in PHP's log file as well.
So I'm coding php on a friends site and the hosting provider has hid the php error log somewhere we haven't been able to find. It would be very useful in debugging the code, is there some code I can add to the top of the script to record the errors in a file I pick?
Edit: I've tried Dagon's suggestion with a test file with the following code:
ini_set("log_errors","1");
error_reporting(E_ALL);
ini_set("error_log", "/actual_file_path/Errors.txt");
print_r(file_get_contents("/actual_file_path/Errors.txt"));
fake_function();
The file path is correct because print_r(file_get_contents("/actual_file_path/Errors.txt")); is printing the text I added to the file. When the page dies form calling fake_function() nothing is recorded in Errors.txt. Really strange.
i have this file and on a click event it calls a php function through $.post{}
i have used alert(data) to recognized errors. But unfortunately its not allerting anything except it shows an error on firebug console with relevant url "Internal server error 500" and then i tried to access the code through browser pasting the full url, I have put error_reporting(E_ALL);
ini_set("display_errors", 1); , but shows a blank page. I'm lost here no idea how to solve this without any errors displaying.. Help much appreciated.
p.s in php info error reporting is off. i tried htaccess on my subfolder without no luck either.
Make sure of the following:
error_reporting(E_ALL) is right after <?php tag
There is indeed a PHP error - try to deliberately make one. Maybe the error is elsewhere, not your PHP but the .htaccess file (since you're getting 500), or maybe it's a logical error.
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.
I want to chceck files before I'll connect domain on my server. I've added them in direct admin, I've uploaded files - but I don't know how to get to them.
I have 4 domains connected, but i have acces only to one. I saw that it's possible to include file from higher level
include('../../panele-podlogowe.eu/adm/img/edit.gif')
That gave me correct image. But when I've done:
include('../../panele-podlogowe.eu/index.php');
Nothing happens (I've turned Error reporting on).
When I did something like:
include('../../panele-podlogowe.eu/index.php');
echo 'Failed?';
Nothing prints out... What the heck?
Solution:
ini_set("display_errors", "stdout");
Review the PHP error log. That usually, even under default settings, shows what's the problem.
Enable error reporting so php will print what is wrong. Add this at the top of your file.
error_reporting(E_ALL);
Otherwise:
Check the access permissions for that file
Double-check the file you are including for syntax errors. (if the include causes php to crash/segfault you might not get any output)