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 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动
  • ¥15 大一C语言期末考试,求帮助🙏🙏
  • ¥15 ch340驱动未分配COM
  • ¥15 Converting circular structure to JSON
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader