mysql_num_rows
Posted: Tue May 10, 2005 6:55 am
Hi there. I was hoping you guys could shed some light on what could possibly be wrong with the mysql_num_rows function I am using. Here is the code:
Basically this function does not work, and either allows access to everyone OR disallows access to anyone, which is useful as you can imagine! I also get this error coming up in accordance to every line with the mysql_num_rows on it:
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/site18/web/hemis_login.php on line 26
Any ideas? Im stumped
Jcart | Please review
Posting Code in the Forums
Code: Select all
<html>
<head>
<title>Coursework Details</title>
</head>
<body>
<?php
require 'connection.php';
if ($_GET['login_query'] === "") {
die("Invalid User: Authentication failed, please ensure that this is a valid HEMIS, please try again<br><br><a href=index.html>Back</a>");
}
else
$login_query = "SELECT * from students WHERE hemis_id = ".$_GET["login_query"].""; //Selects HEMIS from db
$query_run = mysql_query($login_query) or die("Invalid Query: ".mysql_error());
$check = mysql_fetch_array($query_run);
$num_rows = mysql_num_rows($check);
echo ''.$num_rows.'';
if ($num_rows === 0) {
die("Invalid User: Authentication failed, please ensure that this is a valid HEMIS, please try again<br><br><a href=index.html>Back</a>");
}
else {
while ($row = mysql_fetch_array($query_run)) {
echo "Student Name: ".$row['forename']." ".$row['surname']."<br><br>";
}
}
?>
</body>
</html>Warning: Supplied argument is not a valid MySQL result resource in /home/sites/site18/web/hemis_login.php on line 26
Any ideas? Im stumped
Jcart | Please review