Created
December 19, 2017 12:47
-
-
Save hussnainsheikh/9a6cfe809217708fa2b06bccdef480cd to your computer and use it in GitHub Desktop.
Simplet php script to show all DATABASES which are created on a host. Enjoy!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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