"My PHP script works on my server but it does not work on your server."

Most probably, this is due to a difference in the environments of your test server and our live server.

Server Environment

To get an overview of the live server's environment, simply create a "phpinfo.php" script, and put in this line in the script:

<? phpinfo() ?>

After that, upload the "phpinfo.php" script to the server, put it in the "htdocs" folder, and execute the script by going to http://www.my-domain-name/phpinfo.php.

Do the same for your test server, and look out for important differences.

Some very important differences to look out for are:

Version : You may have the impression that as long as the version is newer, it can run any script that used to work in an older version of PHP. This is not strictly true. Newer versions of PHP may deprecate some functions, change their behavior under certain circumstances, or change the API of how other programs should talk to PHP.

Server API : PHP can be compiled in 2 modes, Apache and CGI. This is important because there are some PHP functions that exist only in PHP Apache mode. Take for example, getallheaders. If your script uses this function (or any other other function that works only in PHP Apache mode), then this environment is important to you.

register_globals : If your script contains variables like $DOCUMENT_ROOT, then you'll need to be aware of what this setting does, and how it affects the coding of your scripts.

safe_mode : This setting is important when your scripts need to write or create files and directories, and/or upload files. Applications like Mambo which does a lot of file creation, the "safe mode" setting has certain effects on it.

SCRIPT_FILENAME : You'll need to look out for this if you used absolute paths (for example, /www/mywebsite/script1.php) in your scripts. You'll need to edit your scripts to match the environment of the server.

 

There are many other settings that your PHP script may depend on. It is certainly not very practical for us to crawl through every line of your code and figure out what settings are necessary for the proper function of your script. For every setting that we can spot, we probably would miss out many others.

It is certainly more practical and efficient if you, as the programmer, be aware of the settings that your scripts needs in order for them to function properly. When you arm yourself with this knowledge, it'll go a long way in helping you debug and program effectively. You can simply point out to us that your script needs this particular setting, and we can configure the server accordingly.

Please also note that if your web site is hosted in a shared server, it may not be possible to change every setting. Some changes are server-wide, that is, it affects all web sites in the server. In such a situation, we will not change the setting. Of course, if your site is hosted in your own dedicated server, then there are no such issues.