i have the following php funtion to check for a file on the database
function getAll($what, $tableName, $where=null)
{
global $db_conn;
if($where == null)
{
$query = mysqli_query($db_conn, "SELECT $what FROM `$tableName`");
return $query;
}
else
{
$query = mysqli_query($db_conn, "SELECT $what FROM `$tableName` WHERE $where");
return $query;
}
mysqli_close();
}
function getSingle($what, $tableName, $where=null)
{
$result = getAll($what, $tableName, $where);
$row = mysqli_fetch_array($result);
return $row["$what"];
mysqli_close();
}
function getCount($tableName, $where=null)
{
$result = getAll('*', $tableName, $where);
return mysqli_num_rows($result);
mysqli_close();
}
$error =false;
if(isset($_POST['login']))
{
$status = 'admin';
$email_user='';
$own_email=$_POST['email_user'];
$adm_email=$_POST['email_user'];
$Password = $_POST['Password'];
$staf_username = $_POST['email_user'];
$stu_username = $_POST['email_user'];
$own_email = filter_var($email_user, FILTER_VALIDATE_EMAIL);
$Password = hash('sha256','password');
$Password = strip_tags(addslashes($Password));
$count = getCount('owners_db', "own_email ='$own_email'");
$count1 = getCount('staff_db', "staf_username ='$staf_username' ");
$count2 = getCount('student_db', "stu_username ='$stu_username' ");
$count3 = getCount('admin_db', "adm_email ='$adm_email'");
if ($count != 0) {
$own_id = getSingle('own_id', 'owners_db', "own_email = '$own_email' AND Password = '$Password'");
return;
}
elseif($count == 0){
$error=true;
$errormsg1= '<div id="success" class="alert red">Invalid email or password!</div>';
return;
}
elseif($count == 1){
$_SESSION['own_email'] = $own_email;
$update = update('owners_db', "last_login=now()", "own_email='$own_email'");
header('location: owners_dashboard');
return;
}
this is the error am getting please i need help
<pre>Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74
What I have tried:
this is the error am getting please i need help
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\altech-school\server\dbase\database.php on line 74