简体   繁体   English

在PHP中找不到error_log返回文件

[英]error_log returning file not found in PHP

When I am trying to log the error from my Mysql class its saying file not found 当我尝试从Mysql类记录错误时,找不到说法文件

even though the path is correct 即使路径正确

here is the path 这是路

protected function sql_query($query){
        if (mysqli_query($this->conn,$query)){

                $last_id = mysqli_insert_id($this->conn);
                return $last_id;
            }
            else
                error_log(mysqli_error($this->conn) . "\n", 3, "../var/tmp/sql_error.log");
     }

So the folder looks like this 所以文件夹看起来像这样

donations/api/dbHandeller.php

and the error log file is 错误日志文件是

donations/var/tmp/sql_error.log

ERROR 错误

 error_log(../var/tmp/sql_error.log): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\donations\api\dbHandeler.php

Thanks 谢谢

You're trying to write to a relative path. 您正在尝试写入相对路径。 What you want to do is write to an absolute path, using getcwd() . 您要做的是使用getcwd()写入绝对路径。

error_log(mysqli_error($this->conn) . "\n", 3, getcwd() . "/var/tmp/sql_error.log");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM