3 4
5Successfully connected to the server '" . $hostname . "'
\n"; 83 // printf("MySQL client info: %s\n", mysql_get_client_info()); 84 // printf("MySQL host info: %s\n", mysql_get_host_info()); 85 // printf("MySQL server version: %s\n", mysql_get_server_info()); 86 // printf("MySQL protocol version: %s\n", mysql_get_proto_info()); 87 } 88 if ($link && !$database) { 89 echo "No database name was given. Available databases:
\n"; 90 $db_list = mysql_list_dbs($link); 91 echo "\n"; 92 while ($row = mysql_fetch_array($db_list)) { 93 echo $row['Database'] . "\n"; 94 } 95 echo "\n"; 96 } 97 if ($database) { 98 $dbcheck = mysql_select_db("$database"); 99 if (!$dbcheck) { 100 echo mysql_error(); 101 }else{ 102 echo "
Successfully connected to the database '" . $database . "'
\n"; 103 // Check tables 104 $sql = "SHOW TABLES FROM `$database`"; 105 $result = mysql_query($sql); 106 if (mysql_num_rows($result) > 0) { 107 echo "Available tables:
\n"; 108 echo "\n"; 109 while ($row = mysql_fetch_row($result)) { 110 echo "{$row[0]}\n"; 111 } 112 echo "\n"; 113 } else { 114 echo "
The database '" . $database . "' contains no tables.
\n"; 115 echo mysql_error(); 116 } 117 } 118 } 119 } 120 ?> 121 122