user3251639 user3251639 - 1 year ago 103
PHP Question

ERROR: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given

getting this error in login, I have installed new version of xampp/php still facing lots of problems for mysqli...

below is code for login.php after that it goes to lock.php the code is below...



// username and password sent from form


$sql="SELECT id FROM mc_admin WHERE username='$myusername' and passcode='$mypassword'";


// If result matched $myusername and $mypassword, table row must be 1 row

header("location: home.php");
$error="Your Login Name or Password is invalid";

code for lock.php below:


$ses_sql=mysql_query("select username from mc_admin where username='$user_check' ");



header("Location: login.php");

Answer Source

MYSQL query returns FALSE on error, So one of your queries has an error while executing.

As per PHP docs mysql_query() returns a resource on success, or FALSE on error So before trying to call the mysql_fetch_array check as below:

You can print the error

$result = mysql_query('your query');
if (!$result) {
    die('Invalid query: ' . mysql_error());

Also you must note that now mysql_* functions are deprecated as of PHP5.5. INstead of mysql_* you could use mysqli or PDO

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download