I have a simple self-made MVC structure composed by Controllers, Models and Views.
It was working fine, but now one controller is performing very strange behaviour...
Script gives error 500 (if you check headers) but execution and output is ok.
No error messages, no error log, nothing... but let me tell you the most strangest thing:
if I write debug directives for log information like these
error_reporting(E_ALL);
ini_set('display_errors', 1);
Then error 500 disapears... instead of displaying error information, and work like a charm.
Can't understand this situation. Any help?
Regards
Problem solved. I was using a PHP include which contain some # symbols, for example: #file_get_contents... This is a not recommended practice, now I know why :)
Thanks for your interest
Related
I have a lot of ajax that calls php files to do tasks, like write things to the server. I use load calls so anything the php echoes when it gets into trouble comes back to me. But if I've done something really dumb, like leave off a ")", the PHP doesn't even start and all I get is a cryptic
POST http://www.mysite.com/publishPage.php 500 Internal Server Error
Isn't there something that will tell me "missing ) at line 119" ?
I've placed
ini_set('display_errors', 1);
error_reporting(E_ALL);
at the top of the PHP scripts but that doesn't seem to be helping me here.
Thanks
Syntax errors can not be "checked" if you missed the code, will have to fix before trying to run it.
If you have a syntax error in java, the code will not be compiled. php is not compiled, then this is the solution
I came across an issue today, that my PHP script would send a server error 500 upon finishing (on apache). The code was something like:
//many stuff here that work
echo "It reached here";
exit;
and I was always reaching the point before the exit; command. Doing a google search, I came across this post, which suggested turning on display_errors. I did it and the 500 error went away.
So I wanted to ask, does anyone have an explanation on why this happens? This SO post describes a similar case, but there are no explanations.
As always, thanks in advance
It's pretty likely you get a 500 status code as well, but because PHP echoes something to the browser apache won't jump in and display it's standard status 500 error page.
You would need to verify the actual status code to verify that you won't still get a 500 error.
In case of a fatal error, PHP normally sends a 500 status code. As often the process has failed at that time (hence causing the fatal) and sometime no output is generated since then, the webserver jumps in and gives the user the standard 500-internal-server-error-page.
It appears that the code generated a parse error inside an eval() function in a loop. This kind of error does not break code execution but does produce a 500 error
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 created a captcha just now, and it works PERFECTLY on my own server. On the school's server, it doesn't generate an image. Why might this be? The difference in code is one line.
Edit: Originally, it was working, but I deleted the directory by mistake and I do not know why did it suddenly work in the first place.
Update: I var_dumped() everything and everything is being set correctly.
Source code on school server:
Update: I figured it out! I'll post the answer later.
Make sure that GD library is enabled in your school's server.
Also try putting these lines on top of your script to see if there are any errors:
ini_set('display_errors', true);
error_reporting(E_ALL);
It is just useless to direct such kind of questions to SO.
There must be thousands of reasons.
And, of course, without access to your server and environment, nobody can say, just by looking into working code.
The only person who can answer this question is you yourself.
With help of your server, of course.
You must ask your server for errors.
ini_set('display_errors',1);
error_reporting(E_ALL);
but sometimes (in case of parse errors for example) this won't work. In this case you have to either set these params via .htaccess or check web-server's error log.
Also, you have to do something.
At least add some text output in the script to be sure it being executed.
print out variables using var_dump() to ensure thy contain right values.
Add an intentional error to ensure you CAN see them if any.
Do something, don't sit watching code!
Some more info on how to help yourself: http://www.ibm.com/developerworks/library/os-debug/