PHP Authentication Database Password problem

Source: Internet
Author: User
[/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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.