MySQL connection test

Hostname (usually "localhost")
Username
Password
Database (optional)
Could not connect to the server '" . $hostname . "'

\n"; echo mysql_error(); }else{ echo "

Successfully connected to the server '" . $hostname . "'

\n"; // printf("MySQL client info: %s\n", mysql_get_client_info()); // printf("MySQL host info: %s\n", mysql_get_host_info()); // printf("MySQL server version: %s\n", mysql_get_server_info()); // printf("MySQL protocol version: %s\n", mysql_get_proto_info()); } if ($link && !$database) { echo "

No database name was given. Available databases:

\n"; $db_list = mysql_list_dbs($link); echo "
\n";
		while ($row = mysql_fetch_array($db_list)) {
     		echo $row['Database'] . "\n";
		}
		echo "
\n"; } if ($database) { $dbcheck = mysql_select_db("$database"); if (!$dbcheck) { echo mysql_error(); }else{ echo "

Successfully connected to the database '" . $database . "'

\n"; // Check tables $sql = "SHOW TABLES FROM `$database`"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { echo "

Available tables:

\n"; echo "
\n";
				while ($row = mysql_fetch_row($result)) {
					echo "{$row[0]}\n";
				}
				echo "
\n"; } else { echo "

The database '" . $database . "' contains no tables.

\n"; echo mysql_error(); } } } } ?>