Okay, $result is not the data from the database, but a result set handle. In order to actually make comparisons of database data with 'user-world' data, you need to use various MySQL functions to extract the data from the result set handle.
Suppose a user must enter a userName and a passWord from an HTML form which gets authenticated by comparing that information with the data which resides in a database table named 'users', wherein the columns which store the userName and passWord data are named 'userName' and 'passWord' respectively.
Your user-verification script might look something like this:
// First, build the query:
$query = "SELECT * FROM users WHERE userName='{$_POST['userName']}' AND passWord='{$_POST['passWord']}'";
// Next, try to get a result set handle:
$result = mysql_query($query);
// Verify that you actually *did* get a result set handle:
if(!$result) {
// The query failed, in which case MySQL is generally kind enough to offer a reason why:
exit("Query $query failed: " . mysql_error());
}
// Check that there are rows of data in the result set:
if(mysql_num_rows($result) < 1) {
// There are no rows of data associated with the result set, so we can safely assume that the userName, passWord or both was incorrect:
// This is also a wonderful place to include() a login form...
} else {
// If you got this far, the userName and passWord entered *must* be correct.
// If the userNames are UNIQUE (and they really should be), simply extract the data from the table using fetch_array():
$row = mysql_fetch_array($result, MYSQL_ASSOC);
// Now the data in $row is an associative array which can be used througout the balance of your application:
/**
$row['lastLogin'] = last login date
**/
}
Any help in there?