Fatalerror: Calltoamemberfunctionfetch_array () onanon-objectin62line If ($ _ POST [admin_user]! = "" | $ _ POST [admin_pass]! = "")
{
$ Conn = new mysqli ("localhost", "root", "db_wlgl );
$ Conn-> query ("set names gb2312 ");
$ Admin_user = $ _ POST [admin_user];
$ Admin_pass = ($ _ POST [admin_pass]);
$ SQL = $ conn-> query ("call admin_regs ('". $ admin_user. "', '". $ admin_pass ."')");
$ Res = $ SQL-> fetch_array (MYSQL_BOTH); // 62 rows
If ($ res! = NULL ){
Session_register ("admin_user ");
Session_register ("admin_pass ");
Echo "script alert ('Administrator logon successful! '); Window. location. href = 'indexs. php'; script ";
} Else {
Echo "script alert ('Administrator logon failed! '); Script ";
}
}
?>
Reply to discussion (solution)
Come to the gods, please solve it.
Echo $ conn-> error on line 62; check
$ SQL = $ conn-> query ("call admin_regs ('". $ admin_user. "', '". $ admin_pass ."')");
Execution failed
Echo $ conn-> error;
Look
Echo $ conn-> error on line 62; check
No database selected; it is impossible to select a database.
Echo $ conn-> error on line 62; check
No database selected; it is impossible to select a database.
This is the connection database file conn. php
$ Id = mysql_connect ("localhost", "root ");
Mysql_select_db ("db_wlgl", $ id );
Mysql_query ("set names gb2312 ");
?>
$conn = new mysqli("localhost", "root", "", "db_wlgl);
You didn't see include conn. php, but it is useless because you use mysqli.
$conn = new mysqli("localhost", "root", "", "db_wlgl);
My database does not have a password .. You don't need to fill it out.
You didn't see include conn. php, but it is useless because you use mysqli.
How can this problem be solved?
Isn't the big version on the 7th floor?
Yes? If this parameter is not specified, it is an empty string, but the position still needs to be occupied.
// Your $ conn = new mysqli ("localhost", "root", "db_wlgl); change to $ conn = new mysqli (" localhost "," root ","", "db_wlgl ");
// Your $ conn = new mysqli ("localhost", "root", "db_wlgl); change to $ conn = new mysqli (" localhost "," root ","", "db_wlgl ");
If you have tried it, the same error is still reported ..
Paste your modified code.
$ SQL = $ conn-> query ("call admin_regs ('". $ admin_user. "','". $ admin_pass. "')") or die ($ conn-> error );
Me too. for this solution, please instruct Fatal error: Call to a member function fetch_array () on a non-object in D: \ xampp \ htdocs \ wlgl \ index. php on line 62 $ res = $ SQL-> fetch_array (MYSQL_BOTH );