Warning: mysql_numrows()
Posted: Tue Apr 11, 2006 11:20 pm
Code: Select all
<?
$username="user";
$password="pass";
$database="fedex";
$first=$_POST['first'];
$last=$_POST['last'];
$manager=$_POST['manager'];
$comment=$_POST['comment'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO eval_num VALUES ('','$first','$last','$manager','$comment')";
mysql_query($query);
mysql_close();
?>
<html><body>
<form action="index.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Manager: <input type="text" name="manager"><br>
Comment: <input type="text" name="comment"><br>
<input type="Submit">
</form></body></html>
<?
$query="SELECT * FROM eval_num";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$manager=mysql_result($result,$i,"manager");
$comment=mysql_result($result,$i,"comment");
echo "<b>$first $last</b><br>Manager: $manager<br>Comment: $comment<br>";
$i++;
}
?>Code: Select all
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /opt/lampp/htdocs/fedex/index.php on line 35