Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simplet php script to show all DATABASES which are created on a host. Enjoy!
<?php
$host = 'HOST'; //Hostname or Server ip
$user = 'USER'; //Database user
$pass = 'PASS'; //Database user password
$con = mysql_connect($host,$user,$pass);
if($con){
$count = 0;
$sql = "SHOW DATABASES";
$result = mysql_query( $sql, $con);
if(mysql_query($sql,$con)){
echo $sql."<br> <br>";
while ($row = mysql_fetch_row($result)) {
echo "DATABASE ".++$count.": {$row[0]}<br>";
$table_name = $row[0];
}
echo "<br>Total No. of DATABASES: " . $count;
}
else{
echo "Error in query.";
}
}
else{
echo "Connection Failed.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment