我已经经历了与这个错误有关的所有问题,并做了相应的更改,但错误未得到解决。数据库连接没有错误连接到mysql但在查询数据库时出错。 该错误是mysqli_query()预计参数1是mysqli的,在线路中/Applications/MAMP/htdocs/NuSS_address_api/DB_Functions.php给定对象36 的代码是下面mysqli_query()期望参数1是mysqli,给出的对象
private $con;
//put your code here
// constructor
function __construct() {
require_once('DB_Connect.php');
// connecting to database
$this->con = new DB_Connect();
$this->con->connect();
}
// destructor
function __destruct() {
}
public function isUserExisted($email) {
$con = $this->con;
$sql = "SELECT email from users WHERE email = '$email'";
$result = mysqli_query($con, $sql); //getting error in this line
if (!mysqli_query($con, $sql)) {
echo("Error description: " . mysqli_error($con));
}
$no_of_rows = mysqli_num_rows($result);
echo $no_of_rows;
if ($no_of_rows > 0) {
// user existed
return true;
} else {
// user not existed
return false;
}
}
仅“错误说明:“被显示,但错误没有得到显示
请帮助。
在此先感谢
给我你的'DB_Connect()'内容 –
是'mysqli_error()'还是'mysqli_query()'抛出错误?请将标题与您的问题进行比较并修正。 –
如果你要打印错误,然后使用'mysqli_error()'方法 –