"Throws it right out the window." - Do you get an error message? What does the output look like? Have you tried echo()'ing the $query after they submit to make sure it's not being escaped or something?
Also, try adding some error debugging to your SQL commands, like so:
<?PHP
$db = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $db);
$query = $_POST["query"];
echo "Query was: <b>$query</b><br>\n";
$result = mysql_query($query,$db) or die('MySQL Error: ' . mysql_error($db));
while ($myrow = mysql_fetch_array($result)) {
foreach($myrow as $key => $value)
echo "Column $key has value $value<br>\n";
}
?>
EDIT: You know, perhaps using the CLI would be easier? Try commands like this:
if(get_magic_quotes_gpc())
$query = $_POST['query'];
else
$query = addslashes($_POST['query']);
$exec = exec('mysql --user=mysql_user --password=mysql_password --database=database --html --execute="' . $query . '"', $output);
echo $output;