This question already has an answer here:
what is probably wrong with this my codes?when ever i run it,i keep on getting this error in the browser "Warning: mysqli_query() expects parameter 1 to be mysqli, integer given in C:\wamp\www\login\core\function\users.php on line 4 "..Please i need help. my codes are as below:
user.php
<?php
require('core/database/connect.php');
global $username;
function user_exists($con,$username){
$username = sanitize($username);
$query = mysqli_query($con,"SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'") OR die(mysqli_error());
return (mysqli_fetch_assoc($query) ==1) ? true : false;
}
function user_active($username){
$username = sanitize($username);
$query = mysqli_query($con,"SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `active` = 1") OR die(mysqli_error());
return (mysqli_fetch_assoc($query) ==1) ? true : false;
}
?>
** connect.php***
<?php
$connect_error = 'sorry,we are experiencing connection problem.';
$con = mysqli_connect('localhost','root','') or die($connect_error);
mysqli_select_db($con,'login_registration') or die($connect_error);
?>
function calls
<?php
include 'core/init.php';
if(empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) || empty($password)){
$errors[] = 'You need to enter a username and password';
}else if(user_exists($con,$username) === false){
$errors[] = 'The account dosen\'t exit.Please register';
}else if(user_active($username ) === false){
$errors[] = 'Please u have not login into ur account';
}else{
//here
}
print_r($errors);
}
?>
Please tell me whats wrong with my codes.Thanks in advance
</div>