What If It Doesn t Work?


What If It Doesn't Work?

Unfortunately, plenty of things can go wrong when you first try to get PHP running. If things aren't working right, don't panic; it'll just take a little extra time. You may get a blank page, a file-not-found error, or another kind of error, but the problem can be tracked down.

The first thing to check is whether PHP is running, which, if you're using PHP locally, is easy to check. At the command prompt, change directories to the PHP install directory and run php -v. If the PHP is version displayed, PHP is running. If you can open a command prompt on your ISP using a Telnet or SSH2 application, you can run the same test.

The next item, and the most common issue, is that PHP may not have been installed correctly as far as your server is concerned. This is the problem if you get a blank page, and when you do a "view source" in the web browser, you can see the source code of your PHP script. This means that the web server did not pass the script to PHP to be run. This can be a little finicky, which is why the instructions from www.php.net are so extensive. The best idea is to go through those directions again, line by line, to make sure you did everything just as it's listed.

Then make sure that phpinfo.php is where your web server expects to find it. As mentioned earlier, in Apache, this location is htdocs in the directory where Apache has been installed. For IIS, it's inetpub/wwwroot. In Linux, it may be /var/www/html. The actual directory may be different on various servers; on one PHP server I use, the correct directory is /httpdocs/ROOT, so ask your ISP's tech support. If you've uploaded phpinfo.php to the usual directory on your ISP for your HTML pages and it's not working, ask your ISP's tech support; sometimes they have to enable support on a directory-by-directory basis. For that matter, some ISPs require that you use a different extension for PHP 5 scripts, such as .php5.

NOTE

Do you need any special Unix file protection level for PHP scripts? Must they be set as executables? No, simple 644 protection (not 755) will do.


If you're using IIS, also check php.ini for the line cgi.force_redirect = 0, which must be set as indicated in the installation directions. If you don't see it there, add it.

Finally, take a look at the "Problems?" section in the installation instructions for a troubleshooting guide. The PHP Frequently Asked Questions (FAQ) is at www.php.net/FAQ.php, and it handles many such problems, as does the PHP installation Frequently Asked Questions (FAQ) at www.php.net/manual/faq.installation. You might also check the PHP install archives at http://marc.theaimsgroup.com/?l=php-install&r=1&w=2, or the news groups alt.php or comp.lang.php.



    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net