我一直在看这个错误好几天,我确实找不到错误。
我知道将日志信息放在数据库中并不是标准做法。我通常会使用包含。当我发现错误时,我会改变。
确切的错误是: 警告:mysqli_error()预计在第27行的/home/mjcrawle/class/database.class.php中给出了1个参数0,抱歉无法连接:
我有一个评论//第26行是错误的确切位置
我的数据库文件是......
<?php
// Database Class
class Database {
/* Attributes */
private $host = 'localhost';
private $database = 'xxxxxxxxxxxxxx';
private $username = 'xxxxxxxxxxx';
private $password = 'xxxxxxxxxx';
public $connection;
/*Connection functions*/
function __construct(){
$this->db_connect();
} //ends constructor
/*Destructor function*/
function __destruct() {
} //ends destructor
public function db_connect() {
/*Connection to the DB*/
$conn = mysqli_connect($this->host, $this->username, $this->password)
or die("Sorry unable to connect: " . mysqli_error()); //Connects to server
/ 这是第26行 /
mysqli_select_db($conn, $this->database)
or die("Sorry unable to connect: " . mysqli_error()); //Connect to database
$this->connection = $conn;
}
/*Query the database*/
public function db_query($query){
$result = mysqli_query($this->connection, $query);
return $result;
}
} //End database class
?>
答案 0 :(得分:4)