I am new to MySQL (zero experience) and am studying the book Build your Own Database Driven Website Using PHP & MySQL 4th edition by Sitepoint. I have experience using PHP. Chapters 1 through 3 went fine with no problems. From the mysql command prompt I have created a database, created a table and then added data to the table just as the book describes. The PHP files in chapters 1 through 3 also functioned properly. When I attempted to connect to the database using PHP in chapter 4 is where I am experiencing problems. When the mysqli_connect command is executed, the browser hangs up with no error message. I placed a couple of markers in the file to see which lines were executed. The Marker 1 message is displayed, but the Marker 2 message is not displayed. Here is the code (mostly copied from the book):
<?php
echo 'Marker 1';
$link = mysqli_connect('localhost', 'root', 'mypassword');
echo 'Marker 2';
if (!$link)
{
$output = 'Unable to connect to the database server.';
include 'output.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'))
{
$output = 'Unable to locate the joke (ijdb) database.';
include 'output.html.php';
exit();
}
$output = 'Database connection established.';
include 'output.html.php';
?>
I would expect to eventually receive an error if the connection failed, but it just hangs.
MySQL version: 5.0.22-community-nt
PHP Version: 5.1.4
Apache Version: 2.0.58 (Win32)
Operating Sys: WIN 7 Pro - 64 bit (Intel Core i7-920 processor(8MB L3 Cache, 2.66GHz) 12 gig RAM)
I have been running Apache and PHP for several months with no problems. This is the first time I have attempted to use MySQL.
Any ideas where to look?
Thanks,
Steve