[/IMG] [/IMG]
I am a PHP beginner, wrote a database to verify the user's simple code, regardless of the lost or wrong account password can not be verified. Seek expert guidance
Reply to discussion (solution)
$res = Mysqli_query ($conn, $sql);
if ($row = Mysql_fetch_assoc ($res)) {
MySQL and mysqli are parallel two extensions and cannot be mixed!
$res = Mysqli_query ($conn, $sql);
if ($row = Mysql_fetch_assoc ($res)) {
MySQL and mysqli are parallel two extensions and cannot be mixed!
What should I write to solve the problem
$res = Mysqli_query ($conn, $sql);
if ($row = Mysql_fetch_assoc ($res)) {
MySQL and mysqli are parallel two extensions and cannot be mixed!
Changed to if ($row =mysqli_fetch_assoc ($res)) solved the problem, thanks to the great God
header ("content-type:text/html; Charset=utf-8 "), class cls_mysqli{private $db _host=" localhost "; Private $db _user= "root"; Private $db _password= "root"; Private $db _name= "test"; protected $sql; Public $password; function __construct ($id, $password) {$this->password = $password; $this->sql = "Select password from admin where id = $id"; } function Checkpassword () {Global $link; $link = Mysqli_connect ($this->db_host, $this->db_user, $this->db_password, $this->db_name) or Die ("Database error: " . Mysqli_connect_error ()); $res = Mysqli_query ($link, $this->sql); if ($row _val = Mysqli_fetch_row ($res)) {if ($this->password = = $row _val[0]) {return true; }else{return false; }}}} $query = new Cls_mysqli (1, ' 123 ');p rint $query->checkpassword (); Mysqli_close ($link);
@xuzuning
If structure executes a return, this mysqli resource how to release is reasonable.