I have the following code, and i am having these errors:

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

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

Can somebuddy find out whats the problem? Thanks in advance.

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

<div id="wrapper">

<?php
$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>

        <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>



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

    </form>
<?php
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($count)){
        $something['user_id'];
        $something['user_name'];
        $something['user_pass'];

if ($count > 0){

$_SESSION['user_id'] = $something['user_id'];
$_SESSION['user_name'] = $something['user_name'];
$_SESSION['user_name'] = $something['user_name'];
session_write_close();

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

else{
    echo "<div> Invalid Credentials </div>";
}
}}
}
?>
</div>
<div class="gradient"></div>
</body>
</html>

Recommended Answers

All 3 Replies

Try instead:

$something  = mysql_fetch_array($count);
while ($something = mysql_fetch_array($count)){

write:

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

Thanks, It worked!

You're welcome!

Be a part of the DaniWeb community

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