Testing and Troubleshooting

Testing your installation of PHP is really as simple as writing a small PHP program and running it. Create a small PHP file to use for tests. Write the following code in it:

echo "Hey, it worked";

Save the file as test02.php in any folder within wwwroot (or an appropriate folder if you happen to be running some other OS/Web server combination than Windows 2000/IIS).

Open the file in your browser. You should see the words "Hey, it worked" in your browser. If you see "Page cannot be displayed," there's a problem with your PHP installation or with finding the file, or with the Web server. If you see something that talks about a parse error, you may have made a mistake in entering the code. Coding errors are discussed in more detail in the next few chapters, but in the next section you'll explore some ways you can troubleshoot your basic installation of PHP.

Did the file you tested work? Or are you reading this section right now because the file didn't work? Don't worry; it's very common for problems to occur anytime you try something new, especially when it comes to computers and programming. In fact, consider yourself lucky if it didn't work because you'll learn a lot more about PHP and programming from your mistakes than from your successes.

So let's start at the beginning. Troubleshooting and debugging comprise the process of identifying problems, deducing possible causes, logically isolating those causes until you've identified the most likely culprit, and then trying solutions. The end result is that the problem is fixed and if you've done a good job, you'll have fixed the problem (in an elegant, robust way) without causing other problems.

Chapter 5 covers debugging in more detail; for now, though, let's look at the steps for troubleshooting your installation of PHP:

  1. Check that the Web server is on and running properly. In Windows 2000, do this by checking Services (Start Programs Administrative Tools Services), specifically Internet Admin Services and World Wide Web Publishing Service. Just because these are set to Automatic within Services doesn't mean they are on. Stop and restart them if you need to reassure yourself. You can also check to make sure the Web server is running on the default Web site in Internet Services Manager. For Apache on Linux, check the httpd service (you can also test it by entering http://localhost in your browser).

  2. Place a simple HTML Web page in the wwwroot folder, making sure that it has .htm or .html as the extension for the filename (such as test01.htm), and bring the page up in your browser. Make sure you are using http://localhost/test01.htm to bring up the file, not the file location (such as D:\inetpub\wwwroot\test01.htm).

  3. If the HTML Web page displays properly, you can be sure your Web server is functioning. This implies (assuming your PHP page cannot be displayed) that something is wrong with your PHP installation. Of course, if you see other messages (such as 404 Page Not Found) you may simply not be finding the file properly, so you'd need to take a second look at the file name you chose, the name of your Web folder, and so on.

  4. If you think that something is wrong with your PHP installation, reexamine the installation process you used, going carefully through each step, and make sure you placed all the PHP files in the places they belong. Pay particular attention to the names of Windows and System folders because these may differ depending upon your installation of Windows or Linux.

  5. Check file permissions. File permissions are very important in Linux systems, and to a lesser degree in Windows 2000 or desktop Windows operating systems. You should be logged in as root or administrator on Linux and Windows systems, and should be able to change permissions as necessary to run scripts from within Web server folders. For external hosting accounts any good FTP utility can modify file permissions on Linux systems.

It's likely that following these steps will isolate the problem so that you can fix it.


ALTER SERVER server_name
OPTIONS (option [, option] ...)
Alters the server information for server_name, adjusting any of the options permitted in the CREATE SERVER statement. The corresponding fields in the mysql.servers table are updated accordingly. This statement requires the SUPER [691] privilege.

For example, to update the USER option:


ALTER SERVER does not cause an automatic commit.