Вопрос о функции Php
у меня есть следующая функция php для проверки файла в базе данных
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' "); // this is for the admin $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; }// count
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
Что я уже пробовал:
это ошибка, которую я получаю, пожалуйста, мне нужна помощь
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