Re: resource id #2
| From: | Tobias Talltorp | Date: | Mon, 16 Apr 2001 14:03:40 +0000 |
| Subject: | Re: resource id #2 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48747@lists.php.net to get a copy of this message | ||
> $query=mysql_query("Select pass from members where uname='$username'");
> $result = mysql_query($query)
> or die("You are not authorized to be here.");
<?
$query=mysql_query("Select pass from members where uname='$username'");
$result = mysql_query($query);
// If the number of rows is less than one (meaning zero) then die()
if ($mysql_num_rows($result) < 1)) {
die("You are not authorized to be here.");
}
?>
What you are doing is checking if the query is valid. Your die() would print
only if you had a faulty query (try changing pass to pass2), but if the
username is wrong, it returns an empty set.
The mysql_query() returns the "resource id #2" that you can use with the
mysql_fetch_array, mysql_num_rows etc to get printable information.
// Tobias