mysql test and error
| From: | hE | Date: | Sun, 24 Feb 2008 19:35:43 +0000 |
| Subject: | mysql test and error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-270008@lists.php.net to get a copy of this message | ||
hi,
I found an e-book in the net about php and mysql and with its sample program I am trying to test whether I have mysql working correctly or not. the following program gives error message. why?
<html>
<head><title>Test MySQL</title></head>
<body>
<!-- mysql_up.php -->
<?php3
$host=”localhost”;
$user=”root”;
$password=””;
mysql_connect($host,$user,$password);
$sql=”show status”;
$result = mysql_query($sql);
if ($result == 0)
echo “<b>Error “ . mysql_errno() . “: “
. mysql_error() . “</b>”;
else
{
?>
<!-- Table that displays the results -->
<table border=”1”>
<tr><td><b>Variable_name</b></td><td><b>Value</b>
</td></tr>
<?php3
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo “<TR>”;
$row_array = mysql_fetch_row($result);
for ($j = 0; $j < mysql_num_fields($result); $j++)
{
echo “<TD>” . $row_array[$j] . “</td>”;
}
echo “</tr>”;
}
?>
</table>
<?php3 } ?>
</body></html>