fill in the variables with your mySQL info:
mysql_connect($host, $username, $password);
mysql_select_db($database);
$result = mysql_query('SHOW TABLE STATUS');
$total = 0;
while ($row = mysql_fetch_assoc($result))
{
$total += $row['Data_length'];
}
echo 'the database ' . $database . ' is ' . $total . ' bytes long';