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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀