"mysql_num_rows(): supplied argument is not a valid MySQL result resource in d:\inetpub\wwwroot\test.php"
I get a similar message with mysql_num_row($result) if I remove the If statement. Any ideas?
Here is the code:
Code: Select all
<?
// login to database
require_once ('db_login.php');
?>
<?
// generate and execute query
$sql = "SELECT id, Entry, Description FROM A";
$result = $db->query($sql) or die ("Error in query: $sql. " . mysql_error());
$db->commit();
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through result set
while ($row = mysql_fetch_row($result))
{
?>
<? echo $row->Entry; ?>
<? echo $row->Description; ?>
<br>
<a href="edit.php?id=<? echo $row->id; ?>">Edit</a> |
<a href="delete.php?id=<? echo $row->id; ?>">Delete</a>
<?
}
}
// if no records present display message
else
{
?>
<p>No entries currently available</p>
<?
}
// close connection
// mysql_close($dsn);
?>
<a href="add.php">Add Entry</a>