$today = date("Y-m-d H:i:s"); $file = 'dbsize.txt'; $link = mysql_connect('jiovqmo807.mysql.db', 'jiovqmo807', 'a8axBmYbhfIS'); if (!$link) { die('Not connected: ' . mysql_error()); } $sql="SELECT table_schema 'db_name', SUM( data_length + index_length) / 1024 / 1024 'db_size_in_mb' FROM information_schema.TABLES WHERE table_schema='jiovqmo807' GROUP BY table_schema ;"; $query=mysql_query($sql); $data=mysql_fetch_array($query); file_put_contents($file, $today . ";" . $data['db_size_in_mb'], FILE_APPEND | LOCK_EX);