note 21437 added to function.mysql-num-rows
| From: | cxb at 3xb dot net | Date: | Mon, 13 May 2002 11:07:24 +0000 |
| Subject: | note 21437 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30578@lists.php.net to get a copy of this message | ||
I have tried all of these examples, but I can not get anything to work...
I keep getting a: "Warning: Supplied argument is not a valid MySQL result resource in
/home/cxb/public_html/auth.php on line 18"
This is my code....
<?php
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else if (isset($PHP_AUTH_USER)) {
mysql_connect("localhost", "Blessed", "ultimasucks")
or die ("Unable to connect to database.");
mysql_select_db("Blessed")
or die ("Unable to select database.");
$sql = "select count(id) from users WHERE username='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if ($num != "0") {
echo "<P>You're authorized!</p>";
exit;
}
else {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
}
?>
My problem lies here : $num = mysql_num_rows($result);
But I con not figure out why... I saw all of your examples but nothing has worked.
--
http://www.php.net/manual/en/function.mysql-num-rows.php
http://master.php.net/manage/user-notes.php?action=edit+21437
http://master.php.net/manage/user-notes.php?action=delete+21437
http://master.php.net/manage/user-notes.php?action=reject+21437