<html>
<head>
<title>PHP MySQL Test</title>
</head>
<body>
<font face="Courier New" size="-1">

<h3>MySQL Test</h3>

<?php
    // Syntax: chktable.php?db=<db>&host=<host>

    $mysql_user_name = "root";
    $mysql_user_pass = "";

    if (isset($_GET['db'])) 
        $mysql_db = $_GET['db'];
    else
        $mysql_db = "test";
    if (isset($_GET['host'])) 
        $mysql_server = $_GET['host'];
    else
        $mysql_server = "localhost";

    print "Try to establish connection to mySQL server <font color=blue>$mysql_server</font> database <font color=magenta>$mysql_db</font>...<br>\n";
    $link = mysql_connect($mysql_server, $mysql_user_name, $mysql_user_pass) or die("Could not connect to MySQL database");
    $result = mysql_list_tables($mysql_db);

    for ($i = 0; $i < mysql_num_rows($result); $i++)
        printf ("Table: <font color=red>%s</font><br>\n", mysql_tablename($result, $i));

    mysql_free_result($result);
    mysql_close($link);
?>
</font>
</body>

</html>
Published in: MySQL
Download

Related snippets