Trivial MySQL Interface

This page can be used to submit SQL queries to mysql databases and see the result.
(The "Host name" is the name of the computer on which the database is running.)

Your SQL query:

Host name: 
Username: 
Password: 
Database name: 
$message

\n"); print("\n\n"); die(); } if (!isSet($query)) { // no form data to process; just end the page cleanup(); } print("

Results from your query:

"); // test that we have the necessary data for a mysql query $host = trim($host); $username = trim($username); $password = stripslashes(trim($password)); $database = trim($database); $query = stripslashes($query); if (! ($host && $username && $password && trim($query)) ) cleanup("Error: Missing data. You must fill in the host name, username, password, and query."); // make a database connection if (! (mysql_connect($host,$username,$password)) ) cleanup("Error: Could not connect open connection to $host for $user with password $password."); if ($database && ! (mysql_select_db($database)) ) cleanup("Error: Could not select database $database."); // do the query if ( ! ($result = mysql_query($query)) ) cleanup("Error: Couldn't complete the query. Mysql error was: " . mysql_error() . ""); // Report the results. print("

The query was completed successfully.

\n"); if (is_bool($result) || mysql_num_rows($result) == 0) print("

No result was returned.

\n"); else { print("

The following results were returned:

\n"); print(""); $fields = mysql_num_fields($result); print("\n"); for ($i = 0; $i < $fields; $i++) { $fieldname = mysql_field_name($result,$i); print("\n"); } print("\n"); while ($row = mysql_fetch_row($result)) { print("\n"); for ($i = 0; $i < $fields; $i++) print("\n"); print("\n"); } print("
$fieldname
 $row[$i]
\n"); } cleanup(); ?>