php doesnt show error [closed]

孤街浪徒 提交于 2019-11-29 12:05:52

You might to configure error_reporting (see also), and enable the displaying of errors (see display_errors or ini_set) -- at least on your development machine

In your php.ini file, you'd use

error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On

Or, in your PHP code :

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');

You might also want to install Xdebug on your development box, to get nice stacktraces wehn an error / exception occurs


Of course, on your production machine, you probably don't want to display errors ; so that will have to be configured depending on your environment ;-)

It is almost certainly the case that display_errors is disabled in php.ini.

This is a good thing on product servers, and makes development systems basically unusable.

For a development system you probably want to add one of these lines to you php.ini file:

error_reporting  =  E_ALL & ~E_NOTICE

or

error_reporting  =  E_ALL

Create a file for example test.php with this content:

<?php
phpinfo();
?>

Execute it in your browser and search where the php.ini file is located. Than turn error reporting and displaying errors in php.ini on.

Make sure error_reporting is turned on in php.ini

error_reporting  =  E_ALL | E_STRICT

Make sure in you php.ini file that display_errors is on and set error_reporting to E_ALL.

Start your script with:

<?php
    ini_set ('display_errors', 1);
    error_reporting (E_ALL | E_STRICT);
?>

While the other answers do answer your question, I just wanted to point out that it is best to provide your own error checking routine (or code) so that your script will show pleasant error messages to users. something like

$result=@mysql_query($some_query);
if(!$result){
   if($debugging==TRUE){
       echo($some_query.'<br>'.mysql_error());//shows error in debugging mode
    }
   else{
     log_error()// error logging function
      die( 'there was a problem with your request the problem has been logged and we are working on it');//or something like that

   }
}
//no error
more code
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!