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.