dtqi87613 2015-08-17 21:37
浏览 71
已采纳

在php中启用错误,不会显示某些错误

I have certain problems with error reporting in php. I know that it doesn't report them by default, so i tried every solution i found online.

I used the following code inside my php file:

error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", 1);

And i also edited the php.ini file. Right now it looks like this:

; display_errors
;   Default Value: On
;   Development Value: On
;   Production Value: On

; display_startup_errors
;   Default Value: On
;   Development Value: On
;   Production Value: On

; error_reporting
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL 
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

It works up to a certain point. Errors like syntax errors, for example a missing semicolons show, but when i fix them in my code, i get once again the blank screen. So i believe certain errors still don't show.

The code causing this is a simple php registration form:

<?php

error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", 1);

define('DB_SERVER', 'localhost');
define('DB_USERNAME','root');
define('DB_PASSWORD','');
define('DB_DATABASE', 'maindatabase');

$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);




 function NewUser()
{
    $fname = $_POST['fname'];          
    $lname = $_POST['lname']; 
    $email = $_POST['email'];
    $username = $_POST['username'];    
    $password =  $_POST['password'];   

    $fname = mysqli_real_escape_string($db, $fname);
    $lname = mysqli_real_escape_string($db, $lname);
    $email = mysqli_real_escape_string($db, $email);
    $username = mysqli_real_escape_string($db, $username);
    $password = mysqli_real_escape_string($db, $password);
    $query = mysqli_query($db, "INSERT INTO users (Username, Password, FirstName, LastName, Email) VALUES ('$username','$password','$fname','$lname','$email')"); 

    if($query)
    {
    echo "sucess";
    }
}




if(isset($_POST['submit']))
{
        NewUser();
}

?>

I guess there is some sort of fatal error not showing? What would that be?

Basically what i am asking is what type of error (in the above code and in general) is not displayed, when syntax errors do?

Can someone please give me some perspective, i have tried everything i found on the internet and still nothing.

I am using xampp, on windows 7.

  • 写回答

1条回答 默认 最新

  • duanji1924 2015-08-17 21:46
    关注

    If the error causes a fatal compile-time error, then your script will never even execute, meaning the ini_set() call will never occur.

    You need to set them at the php.ini level, so they'll be in effect when PHP starts up, not AFTER your script has (maybe) started executing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决