* March 3, 2007
* Licensed under the BSD License
*
* A simple little script to interface with a MySQL server over WWW.
* It was written for those times when you need to manipulate a MySQL
* database on a remote server but don't have shell access (only FTP,
* for example) and phpMyAdmin is overkill.
*
* This script passes queries directly to mysql as-is and outputs any
* resulting rows.
*
*/
?>
MySQL Shell
Judd Vinet
jvinet@zeroflux.org
MySQL Shell
$_POST['db_host'],
'name' => $_POST['db_name'],
'user' => $_POST['db_user'],
'pass' => $_POST['db_pass']
);
connect($DB);
$_SESSION['DB'] = $DB;
} else {
connect($_SESSION['DB']);
}
?>
| Host: | |
| Database: | |
| Username: | |
Query failed: ".mysql_error(), false);
}
$rows = @mysql_num_rows($res);
if(!is_numeric($rows)) {
$rows = 0;
}
echo "
\n";
echo "Result: $rows rows
\n";
echo "\n";
for($i = 0; $i < $rows; $i++) {
$row = mysql_fetch_array($res, MYSQL_ASSOC);
if($i == 0) {
// Column Headers
echo "\t\n";
foreach($row as $k=>$v) {
echo "\t\t| $k | \n";
}
echo "\t
\n";
}
echo "\t\n";
foreach($row as $k=>$v) {
echo "\t\t| $v | \n";
}
echo "\t
\n";
}
echo "
\n";
}
?>
Error: $msg";
if($die) {
quit();
}
}
function quit() {
echo "\n";
echo "\n";
exit;
}
?>