-3
PHP 함수는 매우 간단합니다. 그것은 준비된 문장을 사용하여 데이터베이스를 쿼리하는 것이지만, 왜 작동하지 않는지 이해할 수는 없습니다.PHP : 멤버 함수 호출 non-object에서 prepare()
나는 $this->conn
<?php
require_once 'constants.php';
class Mysql {
private $conn;
function ___construct(){
$this->conn = new mysqli (DB_SEVER, DB_USER, DB_PASSWORD, DB_NAME);
if (!$this->conn){
die('There was a problem connecting to the database!');
}
}
function verify_name_and_pass ($un, $pwd) {
$query = "SELECT * FROM users
WHERE username = ? AND user_password = ?
LIMIT 1";
if ($stmt = $this->conn->prepare($query)) {
$stmt->bind_param('ss', $un, $pwd);
$stmt->execute();
if ($stmt->fetch()) {
$stmt->close();
return true;
}
}
}
}
남자,이 질문은 수십억 번 질문되었습니다. 기존 답변을 읽는 데 몇 초를 보내지 않는 이유는 무엇입니까? –
'DB_SEVER' - 오타가 있습니까? – Clive