我已經經歷了與這個錯誤有關的所有問題,並做了相應的更改,但錯誤未得到解決。數據庫連接沒有錯誤連接到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()'方法 –