if(mysql_num_rows($result)) inside if (mysql_num_ro[SOLVED]
Posted: Sat Jul 05, 2008 1:01 pm
Here's my code.
I know there are not enough end brackets, I have some else statements that work so I did not paste them here.
Here's my error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/whatith/public_html/Examples/login.php on line 33
any ideas? I probably should use functions to make this more easier to follow!
Oh yea I have Main.php where the user enters their username/password, when they hit the login button it takes them to the login.php file(which is this file) that verifies the username/password. After I verify the username/password should I call another page to create the users main page?
Code: Select all
$query = "SELECT username, password,lastLogin FROM users WHERE username='$user'";
$result = mysql_query($query);
//verify login information
if (mysql_num_rows($result)){
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if($password == $row['password']){
$query = "UPDATE users SET lastLogin = '$LastLogin' WHERE username = '$user'";
mysql_query($query) or die('Error, query failed');
echo "<center><h2>Welcome $user !</h2></center>";
echo "Last Login was on " . $row['lastLogin'];
echo "<br><br><br><br><a href=search.php?user=$user>Search Users</a>";
//check to see if user has any friends
$query = "SELECT username, friendname FROM Friends WHERE username='$user'";
$result = mysql_query($query);
echo "<br><u><h2>Friends</h2></u>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$friendname = $row['friendname'];
echo $row['friendname'] . " <a href=createmsg.php?friendname=$friendname&user=$user>Send Msg</a><br>";
}
//check for any unread messages
$query = "SELECT user FROM msg WHERE friendname = '$user' and read = '0'";
$result = mysql_query($query);
if (mysql_num_rows($result)){ //here's line 33 where the error occurs.
echo "<br><u><h2><a href = readmsgs.php?user = $user>You have new Mgs</a></h2></u>";
}
Here's my error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/whatith/public_html/Examples/login.php on line 33
any ideas? I probably should use functions to make this more easier to follow!
Oh yea I have Main.php where the user enters their username/password, when they hit the login button it takes them to the login.php file(which is this file) that verifies the username/password. After I verify the username/password should I call another page to create the users main page?