How to get current databases name and User name using PHP

To get Selected database use

$res = mysql_query(“SELECT DATABASE()”) or die(mysql_error());
echo mysql_result($res ,0);

To get current username

$res = mysql_query(“SELECT CURRENT_USER”) or die(mysql_error());
echo mysql_result($res ,0);

Leave a Reply

Your email address will not be published. Required fields are marked *