Results 1 to 2 of 2

Thread: Log In Script problems

  1. #1
    Join Date
    Apr 2014

    Log In Script problems

    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


  2. #2
    Join Date
    Aug 2004
    Well, the error messages seem pretty clear (not providing enough parameters). Have you tried actually looking at the manual pages for those two functions to see what the paramenters are? (Or using OOP syntax so you don't have to keep supplying the MySQLi link resource parameter?)

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center