Grow your CSS skills. Land your dream job.

DB name

  • # February 8, 2013 at 2:11 pm

    in my sidebar.php, I would like to display the WordPress database name used? can I do it and if so, how? trying to find information like this in the codex is like going through a haystack looking for a needle.

    Al

    # February 8, 2013 at 2:47 pm

    Re-posting.

    # February 8, 2013 at 2:47 pm

    < ?php
    // Usage without mysql_list_dbs()
    $link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);
    $res = mysql_query(“SHOW DATABASES”);

    while ($row = mysql_fetch_assoc($res)) {
    echo $row . “n”;
    }

    // Deprecated as of PHP 5.4.0
    $link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);
    $db_list = mysql_list_dbs($link);

    while ($row = mysql_fetch_object($db_list)) {
    echo $row->Database . “n”;
    }
    ?>

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".