Warning:mysql_fetch_array () expects parameter 1 to be resource, boolean given I workaround

Source: Internet
Author: User
Warning:mysql_fetch_array () expects parameter 1 to be resource, boolean given I
$sql = "SELECT count (UID) as user from user_table where uid= '". $this->username. " and password= ' ". MD5 ($this->password,self::userconst)." ' ";
$query = $this->database->setsql ($sql);
if ($row = $this->database->select_array ($query)) {
echo $row ["User"];
Problem query results only one record why can't I read it? If User==1 proves that the user is over 1, it repeats.
The result of his output is:
Warning:mysql_fetch_array () expects parameter 1 to BES resource, boolean given in F:\wamp\www\user\DB\MySql.php on line 27
Please ask for help


PHP Code
  
  Database = new MYSQL ();        $this->username = $u;    $this->password = $p;        } function Register () {$PMD 5 = MD5 ($this->password.self::userconst);        $sql = "INSERT into user_table (Username,password) VALUES ('". $this->username. "', '". $PMD 5. "')";    $database->setsql ($sql);    } function Logout () {echo "logout";    } function Login () {echo "login";        } function Usercheck () {//password plus constant $sql = "SELECT count (UID) as user from user_table where uid= '". $this->username. "        and password= ' ". MD5 ($this->password,self::userconst)." ' ";        $query = $this->database->setsql ($sql);        if ($row = $this->database->select_array ($query)) {echo $row ["User"]; }}}?>


PHP Code
  
  host = "localhost";        $this->username = "root";        $this->password = "";        $this->database = "Bkqs";     $this->mysqlconnection ();  } function Mysqlconnection () {$connection = mysql_connect ($this->host, $this->username, $this->password)        Or Die ("Connection Database Failed");        mysql_select_db ($this->database, $connection) or Die ("Open database Failed");     mysql_query ("Set names ' GBK '");     } function SetSQL ($sql) {return mysql_query ($sql);     } function Select_array ($query) {return mysql_fetch_array ($query);     } function Select_object ($query) {return mysql_fetch_object ($query);     } function Close () {return mysql_close (); }}?>



------Solution--------------------
The SQL statement execution failed. You can add an error message to your SetSQL () method. Or Die (Mysql_error ()); Know where the mistake is.
  • 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.