Warning: mysql_fetch_array () handle, booleangiveni $ SQL = & quot; selectcount (uid) asuserfromu 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"];
Why can't I read only one record in the query results? if user = 1, it indicates that the user 1 or above is repeated.
The output result is:
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in F: \ wamp \ www \ user \ DB \ MySql. php on line 27
Ask for help
PHP code
Database = new MySql (); $ this-> username = $ u; $ this-> password = $ p;} function register () {$ pmd5 = md5 ($ this-> password. self: USERCONST); $ SQL = "insert into user_table (username, password) values ('". $ this-> username. "','". $ pm5. "')"; $ 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 ("failed to connect to the database"); mysql_select_db ($ this-> database, $ connection) or die ("failed to open the database "); 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 --------------------
An error occurred while executing the SQL statement. You can add error messages in your setSQL () method. Or die (mysql_error (); you will know where the error is.