PHP error on button controller
<p>I have a little problem finding the error for the controller in Delete button. The problem is that if I only display the jokes (2º part of the code), it works fine, it display the list of jokes and the button to delete each joke. The problem is when I insert the controller part of the delete button the website just doesn't respond... I can't seem to find the error. Even if there is an error in the whole "if statement", wouldn't only be showing off once I actually press the button, instead off making the whole website (including the html part) crash? </p>

<p>The error is <code>Error 324 (net::ERR_EMPTY_RESPONSE)</code>.</p>

<p>Thanks in advance for the patience.</p>

<pre><code>&lt;?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/magicquotes.inc.php';

if (isset($_POST['action']) and $_POST['action'] == 'Delete')
{
include $_SERVER['DOCUMENT_ROOT'].'/includes/db.inc.php';
$id = mysqli_real_escape_string($link, $_POST['id']); 


$sql="SELECT id FROM joke WHERE authorid='$id'";
$result=mysqli_query($link,$sql);

if(!$result)
{
    $error = 'Error getting jokes to delete';
    include 'error.html.php';
    exit();
}


while ($row = mysqli_fetch_array($result))
{
    $jokeId = $row[0];

    $sql = "DELETE FROM jokecategory WHERE jokeid='$jokeid'";

    if(!mysqli_query($link,$sql))
    {
        $error = 'Error deleting category entries for joke';
        include 'error.html.php';
        exit();
    }
}

$sql = "DELETE FROM joke WHERE authorid='$id'";

if(!mysqli_query($link, $sql)
{
    $error = 'Error deleting jokes for author';
    include 'error.html.php';
    exit();
}

$sql = "DELETE FROM author WHERE id='$id'";

if(!mysqli_query($link, $sql)
{
    $error = 'Error deleting author';
    include 'error.html.php';
    exit();
}

header('Location: .');
exit();
}
</code></pre>

<p>Only this part below works</p>

<pre><code>include $_SERVER['DOCUMENT_ROOT'].'/includes/db.inc.php';

$result = mysqli_query($link, 'SELECT id, name FROM author');
if(!$result)
{
$error='Error fetching authors from database';
include 'error.html.php';
exit();
}

while($row = mysqli_fetch_array($result))
{
$authors[] = array('id'=&gt;$row['id'], 'name'=&gt; $row['name']);
}

include 'authors.html.php';

?&gt;
</code></pre>
