I have the following code to login in my php page. Whenever I enter my username & Password & hit login, I get the following error.

Warning: mysql_fetch_array() expects parameter 1 to be resource, integer given in C:\xampp\htdocs\fyp\qmc-login\login.php on line 59

here is my code:

<?php include_once("../includes/connection.php"); ?>
<!DOCTYPE html>
<html lang='en'>
    <meta charset="UTF-8" /> 
        HTML Document Structure
    <link rel="stylesheet" type="text/css" href="style.css" />

<div id="wrapper">

$current_page = $_SERVER['PHP_SELF'];
    <form name="login-form" class="login-form" action= "<?php echo $current_page; ?>" method="post">

        <div class="header">
        <h1>Login Form</h1>
        <span>Fill out the form below to login to my super awesome imaginary control panel.</span>

        <div class="content">
        <input name="username" type="text" class="input username" placeholder="Username" />
        <div class="user-icon"></div>
        <input name="password" type="password" class="input password" placeholder="Password" />
        <div class="pass-icon"></div>     

        <div class="footer">
        <input type="submit" name="button" value="submit" class="button" />
        <a href="../qmc-reg/reg.php" style="color:#000" >  Register</a>

if (isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];

$query_one  = "SELECT * ";
$query_one .= "FROM users ";
$query_one .= "WHERE user_name = '".$username."' ";
$query_one .= "AND user_pass = '".$password."' ";
$query_one .= "LIMIT 1";

$result = mysql_query($query_one) or die(mysql_error());
$count = mysql_num_rows($result) or die(mysql_error());

if ($count == 1){
$something  = mysql_fetch_array($count);

while ($something = mysql_fetch_array($result)){

if ($count > 0 ){

$_SESSION['user_id'] = $something['user_id'];
$_SESSION['user_name'] = $something['user_name'];
$_SESSION['user_pass'] = $something['user_pass'];

$salt = "cas212c";
$hash = sha1($password, $salt);

if ($password == $hash){


header("location: ../cms/cms.php");

    echo "<div> Invalid Credentials </div>";
<div class="gradient"></div>

Recommended Answers

remove line 59, its not needed and parameter is also wrong in that line

Jump to Post

All 2 Replies

remove line 59, its not needed and parameter is also wrong in that line

I don't think all your curly braces are in the right place either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.