No uses magic_quotes_gpc, este se puede bypassear, alguna veces la comodidad no es lo mejor para poner proteccion, mejor pasa todo por htmlentities(), ok a lo que vamos, asi quedaria mejor, si las variables del formulario no contiene ningun valor no se ejecuta el if principal, te recomiendo que las variables del formulario la guardes en una variable porque estar haciendo $_POST['aaaa'], te puede confundir, es mejor tratar de hacer codes limpios asi te evitas problemas o lo resuelves mas facir xD, asi quedaria mejor:
<?php
/*Program: mysql_send.php
*Desc: PHP program that sends an SQL query to the
* MySQL server and displays the results.
*/
echo "<html>
<head><title>SQL Query Sender</title></head>
<body>";
if(ini_get("magic_quotes_gpc") == "1") {
}
$host="mysql.webcindario.com";
$user="libertyelche";
$password="******";
/* Section that executes query and displays the results */
if(!empty($_POST['database']) && !empty($_POST['query'])) {
echo "Database Selected: <b>{$_POST['database']}</b><br>
Query: <b>{$_POST['query']}</b>
<h3>Results</h3><hr>";
if($result == false)
{
}
{
echo "<h4>Query completed.
No results returned.</h4>";
}
else
{
/* Display results */
echo "<table border='1'><thead><tr>";
{
"</th>";
}
echo "</tr></thead>
<tbody>";
{
echo "<tr>";
foreach($row as $value)
{
echo "<td>".$value."</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
}
/* Display form with only buttons after results */
echo "<hr><br>
<form action='{$_SERVER['PHP_SELF']}' method='POST'>
<input type='hidden' name='query' value='$query'>
<input type='hidden' name='database'
value={$_POST['database']}>
<input type='submit' name='queryButton'
value='New Query'>
<input type='submit' name='queryButton'
value='Edit Query'>
</form>";
}
/* Displays form for query input */
if (@$_POST['queryButton'] != "Edit Query")
{
$query = " ";
}
else
{
}
?>
<form action="<?php echo $_SERVER['file:///C|/Documents and Settings/Jonatan/Mis documentos/Downloads/PHP_SELF'] ?>"
method="POST">
<table>
<tr><td style='text-align: right; font-weight: bold'>
Type in database name</td>
<td><input type="text" name="database"
value=<?php echo @$_POST['database'] ?> ></td>
</tr>
<tr><td style='text-align: right; font-weight: bold'
valign="top">Type in SQL query</td>
<td><textarea name="query" cols="60"
rows="10"><?php echo $query ?></textarea></td>
</tr>
<tr><td colspan="2" style='text-align: center'>
<input type="submit" value="Submit Query"></td>
</tr>
</table>
<input type="hidden" name="form" value="yes">
</form>
</body></html>