Hi Guys,

I'm having a few issues, I have managed yo let users register this works fine. But When the registerd user tries to log into the site I'm getting the following error message

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\login.php on line 16

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\login.php on line 16

This is my code

// checkLogin.php

session_start(); // Start a new session
require('config.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['username'];
$password = $_POST['password'];

// Do some basic sanitizing
$username = stripslashes($username);
$password = stripslashes($password);

$sqli = "select * from 'users' where username = '$username' and password = '$password'";

$result = mysqli_query($sqli) or die ( mysqli_error() );
$count = 0;
while ($line = mysqli_fetch_assoc($result)) {

if ($count == 1) {

     $_SESSION['loggedIn'] = "true";

     header("Location: loginSuccess.php"); // This is wherever you want to redirect the user to

} else {

     $_SESSION['loggedIn'] = "false";

     header("Location: loginFailed.php"); // Wherever you want the user to go when they fail the login



Any ideas? All help is much appreicated

3 Years
Discussion Span
Last Post by Sammys.Man

Se the manual - the procedural style part. The mysqli_query expects two parameters, the link and the query. Similar goes for the mysqli_error. It expects the link in procedural version.

Edited by broj1


try changing your dashes
you have

$sqli = "select * from 'users' where username = '$username' and password = '$password'";

try (look at the users)

$sqli = "select * from `users` where username = '$username' and password = '$password'";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.