Printing MySQL Show status on webpage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpwatcher
Forum Newbie
Posts: 1
Joined: Mon Nov 23, 2009 9:21 am

Printing MySQL Show status on webpage

Post by phpwatcher »

Hi

I was trying the following basic code which returns the "show status" command from MySql

Code: Select all

 
 
<html>
<head><title>Test MySQL</title></head>
<body>
<!-- mysql_up.php -->
<?php
$host=”hostname”;
$user=”mysqlaccount”;
$password=”mysqlpassword”;
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>
<?php
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>
<?php } ?>
</body></html>
 
I see that the above code isnt throwing any results on to the Mozilla browser but when I run it on Nusphere PHP edit it works fine.

I checked APache services and they are running fine..

I changed ServerName value in the httpd.conf to localhost:80
Can anyone help me with the problem?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Printing MySQL Show status on webpage

Post by papa »

Hm, you can start off by changing all your quotes “ ” to " ".
Post Reply