dtqi87613 2015-08-17 13:37 采纳率: 0%
浏览 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 13: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.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部