Deletejoke PHP script causes Apache to stop working
Problem: Deletejoke PHP script causes Apache to stop working. All previous scripts in Build Your Own Database Driven Web Site Using PHP & MySQL, Fourth Edition run without a problem. I have verified MySQL tables set-up, and of course, I'm using the appropriate password for my sys. Search in archives and the web for this problem inconclusive. I don't think it's a scripting issue. Apache running locally on my laptop. All "Include" files are where they are supposed to be. Can anybody help me? Thanks in advance!
Basic computer info:
Windows Vista Home Premium 2007, w/ Service pack 1
VAIO Computer, Intel(R) Core(TM)2 Duo CPU T5250 @ 1.50GHz, 1.0 GB RAM, 32-bit OS
Message from IE version 8.0:
Internet Explorer cannot display the webpage
Message from windows pop-up window:
Apache HTTP Server stopped working and was closed
error.log:
[Tue Jul 14 09:28:49 2009] [notice] Parent: child process exited with status 255 -- Restarting.
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.32 for ServerName
[Tue Jul 14 09:28:54 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.10 configured -- resuming normal operations
[Tue Jul 14 09:28:54 2009] [notice] Server built: Dec 10 2008 00:10:06
[Tue Jul 14 09:28:54 2009] [notice] Parent: Created child process 5376
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.32 for ServerName
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.32 for ServerName
[Tue Jul 14 09:28:54 2009] [notice] Child 5376: Child process is running
[Tue Jul 14 09:28:54 2009] [notice] Child 5376: Acquired the start mutex.
[Tue Jul 14 09:28:54 2009] [notice] Child 5376: Starting 64 worker threads.
[Tue Jul 14 09:28:54 2009] [notice] Child 5376: Starting thread to listen on port 8080.
Here is the PHP Script (from Chapter 4, Build Your Own Database Driven Web Site Using PHP & MySQL, Fourth Edition:
<?php
if (get_magic_quotes_gpc())
{
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
if (isset($_GET['addjoke']))
{
include 'form.html.php';
exit();
}
$link = mysqli_connect('localhost', 'root', 'password');
if (!$link)
{
$error = 'Unable to connect to the database server.';
include 'error.html.php';
exit();
}
if (!mysqli_set_charset($link, 'utf8'))
{
$output = 'Unable to set database connection encoding.';
include 'output.html.php';
exit();
}
if (!mysqli_select_db($link, 'ijdb'))
{
$error = 'Unable to locate the joke database.';
include 'error.html.php';
exit();
}
if (isset($_POST['joketext']))
{
$joketext = mysqli_real_escape_string($link, $_POST['joketext']);
$sql = 'INSERT INTO joke SET
joketext="' . $joketext . '",
jokedate=CURDATE()';
if (!mysqli_query($link, $sql))
{
$error = 'Error adding submitted joke: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
header('Location: .');
exit();
}
$result = mysqli_query($link, 'SELECT id, joketext FROM joke');
if (!$result)
{
$error = 'Error fetching jokes: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
$jokes[] = array('id' => $row['id'], 'text' => $row['joketext']);
}
include 'jokes.html.php';
?>