Warning: mysql_fetch_assoc() expects parameter 1 to be resource, integer given in

Sultan

New member
C:\wamp\www\login.php ? Warning: mysql_fetch_assoc() expects parameter 1 to be resource, integer given in C:\wamp\www\login.php on line 21

login.php code here

<?php

session_start();

$email = $user = (isset($_POST['email'])) ? $_POST['email'] : '';
$password = $user = (isset($_POST['password'])) ? $_POST['password'] : '';

if ($email&&$password)
{
//connection to mysql
$connect = mysql_connect("localhost","root","") or die("Couldn't connect..");
//connecting database
mysql_select_db("phplogin") or die("Couldn't find db");
//selecting data from table
$query = mysql_query("SELECT * FROM users WHERE email='$email'");
//checking email

$numrows = mysql_num_rows($query);
//for albums

$fieldarray = mysql_fetch_assoc(mysql_num_rows($query));

$id = $fieldarray['id'];
echo $id;

//end for albums
if ($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbemail = $row['email'];
$dbpassword = $row['password'];
}
//check to see if they match
if ($email==$dbemail&&md5($password)==$dbpassword)
{
//for album
$_SESSION['id']=$id;
//end for album
echo "You are logged in $email. <a href='user.php'>Click here</a> to enter the member page.";
$_SESSION['email']=$dbemail;
}
else
echo "Incorrect password..";
}
else
die("That email doesn't exist");

}
else
die("Please enter a email and password.");

?>
 
Back
Top