(SORRY, to make a double post but i got the topic of the other one wrong and i didint se an edit button )
anhow
hello, im using a php script to show the size of my sql database but im having a problem with connecting,
1: as i tryed to start the SQL server it's saying it is already running
2: i can connect to the database with mysql query browser and 2 schemes are added "mysql" and "rizzler"
3: after setting up the script (code bellow) i get nothing but a white screen, why is this? it's like it cant connect for some reason, still the mysql server is running.
i dont even get an error saying (cannot_connect) i use php5
***************CODE*************
<html>
<head><title>mySQL database size</title></head>
<body>
<h1>MySQL Database Size</h1>
<?php
function file_size_info($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
$file_size_info['size'] = ceil($filesize);
$file_size_info['type'] = $bytes[$i];
return $file_size_info;
}
$db_server = 'localhost';
$db_user = 'root';
$db_pwd = 'passwordwasremoved';
$db_name = 'rizzler';
$db_link = @mysql_connect($db_server, $db_user, $db_pwd)
or exit('Could not connect: ' . mysql_error());
$db = @mysql_select_db($db_name, $db_link)
or exit('Could not select database: ' . mysql_error());
// Calculate DB size by adding table size + index size:
$rows = mysql_query("SHOW TABLE STATUS");
$dbsize = 0;
while ($row = mysql_fetch_array($rows)) {
$dbsize += $row['Data_length'] + $row['Index_length'];
}
print "database size is: $dbsize bytes<br />";
print 'or<br />'; $dbsize = file_size_info($dbsize);
print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>
</body>
</html>
anhow
hello, im using a php script to show the size of my sql database but im having a problem with connecting,
1: as i tryed to start the SQL server it's saying it is already running
2: i can connect to the database with mysql query browser and 2 schemes are added "mysql" and "rizzler"
3: after setting up the script (code bellow) i get nothing but a white screen, why is this? it's like it cant connect for some reason, still the mysql server is running.
i dont even get an error saying (cannot_connect) i use php5
***************CODE*************
<html>
<head><title>mySQL database size</title></head>
<body>
<h1>MySQL Database Size</h1>
<?php
function file_size_info($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
$file_size_info['size'] = ceil($filesize);
$file_size_info['type'] = $bytes[$i];
return $file_size_info;
}
$db_server = 'localhost';
$db_user = 'root';
$db_pwd = 'passwordwasremoved';
$db_name = 'rizzler';
$db_link = @mysql_connect($db_server, $db_user, $db_pwd)
or exit('Could not connect: ' . mysql_error());
$db = @mysql_select_db($db_name, $db_link)
or exit('Could not select database: ' . mysql_error());
// Calculate DB size by adding table size + index size:
$rows = mysql_query("SHOW TABLE STATUS");
$dbsize = 0;
while ($row = mysql_fetch_array($rows)) {
$dbsize += $row['Data_length'] + $row['Index_length'];
}
print "database size is: $dbsize bytes<br />";
print 'or<br />'; $dbsize = file_size_info($dbsize);
print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>
</body>
</html>