I am fairly new to programming using PHP and MySQL. I have been reading Kevin Yank's book titled, "Building a Database-Driven Web Site Using PHP and MySQL". I'm at the very beginning where I'm trying to make an initial connection to my test database in order to display the four records via Internet Explore. The problem is.......I can't get it to work and I've been trying different processes of elimination for over 3 hours - Ouch! I've attached my simple code below. My MySQL server (localhost), database (event) and one table (volunteers) are working just fine, as I'm able to do everything from the command line that I want.

I've think I've pinpointed the problem to the initial MySQL connection string. It doesn't seem to be making the initial connection to the MySQL server which is on the same workstation I'm programming on, however I have no proof of this. I've tried to find out the value of $dbcnx using echo, but no luck.

I feel like I'm missing something really basic. The only thing that appears when I run the page below are the two lines at the top. Other sample PHP code runs just fine on my workstation, as long as it isn't connecting to a MySQL database on localhost. BTW, I haven't seen any of the error trapping messages in the code below, even though my understanding is that I should if there's problem connecting to MySQL, the database, etc?

Any ideas? I've done a considerable amount of programming in the past using Fortran, VBScript, C+, etc., so I'm not new to programming. The fact is I've run into many, many scenarios where the problem turns out to be "that one little thing" I overlooked. The book discusses version 4.x of PHP and I downloaded and installed version 5.2.3, if that makes any difference. I do notice that if I purposely put a syntax error into my PHP code, a blank page appears instead of a page with the top 2 lines. This has helped me rule out a syntax issue, I think.

I've been told PHP and MySQL are so easy, so this is making me very frustrated as you can imagine. Any assistance would be greatly appreciated!

(P.S. Yes, "password" is my root password, in case you are wondering after seeing the code below.)

--Chris
chrisrima@gmail.com

*****************
<HTML><HEAD><TITLE> Event 2007 - Volunteer Registration </TITLE></HEAD><BODY>

<P><H1>Event 2007</H1><P>
<P><H2>Volunteer Check-In</H2><P>

<?php

$dbcnx = mysql_connect("localhost", "root", "password");

if (! $dbcnx) {
echo( "<P>Unable to connect to the database server at this time.</P>" );
exit();
}

if (! @mysql_select_db("event") ) {
echo( "<P>Unable to locate the volunteers database at this time.</P>" );
exit();
}

mysql_select_db("event", $dbcnx);

$sql1 = "SELECT * FROM volunteers";

$result = mysql_query($sql1);

if (! $result) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
}

while ( $row = mysql_fetch_array($result) ) {
echo("<P>" . $row["FirstName"] . "</P>");
}

?>

</BODY></HTML>
********************