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 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题