I was checking our this tutorial on authenticating users against a database. But for some reason, this line:
$num = mysql_numrows($result);
never works. I was forced to write my code another way because that function is undocumented in the manual (though mysql_num_rows is, but that doesn't work either). Anyone know about this?
// connect to MySQL
mysql_connect("hostname", "username", "password")
or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db("dev_i2ii_com")
or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT *
FROM users
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
$num = mysql_numrows($result);
never works. I was forced to write my code another way because that function is undocumented in the manual (though mysql_num_rows is, but that doesn't work either). Anyone know about this?
// connect to MySQL
mysql_connect("hostname", "username", "password")
or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db("dev_i2ii_com")
or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT *
FROM users
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
