Gossamer Forum
Home : General : Databases and SQL :

PHP / MySQL help

Quote Reply
PHP / MySQL help
Hey guys got a problem with MySQL statement.

I'm just a beginner and i'm trying to setup a template for a site I would like designed. I am at trying to get a login page to work in PHP / MySQL.

However I am getting an error when I try logging in.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/aboutstb/public_html/test/login.php on line 8

<?
include ("includes/db.php");
if (($username) AND ($password)) {
// you should inspect these variables before passing off to mySQL
$query = "SELECT username, password FROM user ";
$query .= "WHERE user='$username' AND pass='$password'";
$result = mysql_query($query, $dbh);
if(mysql_num_rows($result)) {
// we have at least one result, so update the logged in datetime
$query = "UPDATE from login SET logged=SYSDATE()";
$query .= "WHERE user='$username' AND pass='$password' ";
mysql_query($query,$mysql_link);
} else {
print("Sorry, this login is invalid.");
exit;
}
} else {

?>
<form action="<? echo $PHP_SELF?>" method="POST">
User: <input type="text" name="username">
Pass: <input type="password" name="password">
<input type="submit" value="Submit"></form>
<?
}
?>

The include for the database connection is correct. So it's not there it's after somewhere on line 8 which is the following line:

if(mysql_num_rows($result))

Any help would be greatly appreciated.

Nick
Subject Author Views Date
Thread PHP / MySQL help nickXrider 6337 May 16, 2003, 4:43 PM
Thread Re: [nickXrider] PHP / MySQL help
Paul 6072 May 16, 2003, 5:06 PM
Thread Re: [Paul] PHP / MySQL help
nickXrider 6099 May 16, 2003, 5:32 PM
Post Re: [nickXrider] PHP / MySQL help
Andy 6013 May 17, 2003, 5:29 AM