Showing results for 
Search instead for 
Did you mean: 

Scripts: Common PHP Problems


Scripts: Common PHP Problems

Tutorials & FAQs: Scripts: Common PHP Problems

Some preliminary advice
  • Make sure that you have read the Force9 Customer support pages - they contain lots of useful and relevant information.

  • The Tutorials & FAQs forum contains a number of related articles including:
  • Neither PHP nor Perl cgi will work at all on Force9 if you have not activated CGI using the Force9 Portal. For many PHP and Perl applications, you probably also need to activate MySQL.

  • Currently, you can activate both these special Force9 website services from the Portal's Website settings facility. (NB: If options to perform these functions do not appear on the Website settings page, your account type does not include them, and you need to upgrade if you want these features.)

  • Your software should be uploaded to the server named

    If you are installing PHP software, do not install it anywhere inside the directory (folder) called cgi-bin, including its subdirectories if there are any. Create a new folder, outside cgi-bin, but still on the server, and put your PHP files in there.

    You should install Perl software inside cgi-bin.

  • Before you start uploading your files, make absolutely certain that your FTP program is correctly set up to transfer files with extensions .pl, .PL, .php, .PHP, .php3, .PHP3, .php4, .PHP4 as ASCII.

    Also make absolutely sure that other files, such as images will be correcty uploaded as BINARY.

    If you use command-line FTP, use the "ascii" or "bin" command to specify the correct type of transfer prior to initiating the "put" or "mput" operation.

  • Once you have uploaded your files, make sure that all PHP files have their permissions set correctly. This generally means that they should all be World executable by having the permission index 705.

  • You can normally set the permissions by right clicking on the selected file(s) and selecting Properties, Permissions or CHMOD. (Sometimes you have to use the main menu to do this.)

    Not all FTP programs let you set the permissions. Make sure that yours can or none of your PHP files will work. An excellent, free FTP client which does work well is SmartFTP which you can also get from

You do not have access to this file

This usually means that you have forgotten to set the permissions correctly. Make sure that the directory (folder) your file is inside is execuable by all and that the PHP files inside it are also executable by all. IE that they have the permission index 705.

I get a server configuration error

This error can occur if you have forgotten to make sure that your FTP program is uploading the PHP files as ASCII.

I get blank pages with no output

The PHP program is probably trying to use MySQL and one of the following problems exist:

Note: If you are new to all this, these instructions may seem complicated at first sight, but they are really very simple to follow, just take your time and read each step carefully before you do it.
  • You have not yet activated MySQL using the Force9 Portal.

  • You have not edited the file config.php so that it has the correct values.

    Note: Never change a Perl (.pl), PHP (.php) or SQL (.SQL) file with a word processor like Word, Office or Claris. Use a simple text editor like Notepad.

    This is usually a very simple process which involves typing in the correct details as given you by Force9. Usually, instructions for changing the config.php file are contained inside the file and you only need to change the following bits of information:

    • $dbhost = "localhost";
      The name of the Force9 database host, at the moment, you should be changing localhost to either humbug or rumpus.
    • $dbuname = "username";
      The Force9 username that you use to log in to the portal, eg jacob.
    • $dbname = "username_f9";
      The name of the database that Force9 has created for you to use, eg jacob_f9
    • $dbpass = "";
      The password that Force9 sent you when you activated MySQL using the Force9 Portal. Currently, you can activate the special Force9 website services from the Portal's Website settings facility.
    • $prefix = "this_app";
      Many PHP programs let you customise the database tables they use by defining a prefix. They do this so that two different programs will not both be trying to use the same table. For example, most PHP programs will want to have a table called users. But, they cannot all use the same table so good PHP programs let you give their tables a prefix. That way, two programs, eg WebChess and Accounts can both have users tables but they will be called, for example, wc_users and acct_users. If you get an option to set the prefix, set it to something indicative of the program, like wc or acct. If you do not get this option, make sure to backup your existing database before you run the new program for the first time, just in case the new program tries to use a table that another program is already using.
    • $user_prefix = "username";
      Erk! I don't really know what this one is for myself yet.
    • $dbtype = "MySQL";
      On Force9, the database type should always be MySQL. If the program you are trying to install does not support MySQL, it will not run on Force9.

  • You have not installed the SQL tables correctly.

    Many PHP programs need you to set up a database that they can use while they work. Read any documentation that comes with the program. It is particularly important to read any files called readme or install as these usually contain vitally important information about getting the program to work.

    Some programs will tell you a specific file that must be run to install the program and its tables into your database. Note that it will not be able to do that if you have not first correctly set any values needed in config.php.

    Other programs will ask you to manually set up the required tables by copying the contents of a file into your Force9 database. You can do that by using the Advanced Tool, phpMyAdmin in the Force9 Portal (eg, from the Advanced tools link).

    Important note: if the config.php allowed you to set a prefix, then you must make sure that you have changed the prefix in the database file.

    Supposing the file they tell you that you have to insert into your database is called database.sql. You need to open the file in a text editor (Not a word processor like Word, Office or Claris, but a simple text editor like Notepad. The same goes for all PHP files. Do not use a word processor to change them). Once you have opened the file you need to make sure that the databases all have the correct prefix.

    Look for a line near the top like

    CREATE TABLE prefix_databasename

    then go to the menu and select Edit::Replace. You need to

    replace every prefix_with my_prefix_

    where prefix is the first word before the '_' after TABLE and my_prefix is what you typed into the config.php file.

    To use the phpMyAdmin tool, you need to select your Force9 database host (rumpus or humbug) and then click Go. You will then be asked for your username (the same one you use to login to the Portal) and the pasword for your database (not the same one you use to login to the Portal, the one they sent you in an email after you activated MySQL).

    Once you have logged in click the word username_f9 right under Home in the top left. Once the page has updated, click the word SQL which appears at the top of the page on the right.

    Now go back to your Notepad with database.sql in it. Select all the text and then copy it to the clipboard.

    Go back to the MySQL admin wepbage and paste all that text into the large white box on the right. This may take a while to complete, be patient.

    Once the mouse no longer shows as busy (maybe a bee or an hourglass), click the Go button at the bottom.

    It usually takes a couple of minutes for the next page to appear, and it can take five or ten minutes before the update is comple. Be patient and wait until the page updates or you may have to start all over again.

    If an error message comes up saying the query failed, you may need to get more detailed help on one of the community forums.

    If a page come up saying the new page cannot be displayed, it is probably only a minor error. Try clicking the username_f9 link to see if the query has actually worked and your new tables get displayed on the left.

  • There is an error somewhere in the PHP program.

    If you know that:

    • You have turned on PHP and MySQL in the Force9 Portal
    • The details in config.php are correct
    • Your PHP files have been correctly uploaded as ASCII
    • Your PHP files all have the correct permission (705)
    • Your .SQL file has been edited and the prefix has been set correctly
    • You have successfully inserted your .SQL file into your Force9 database
    and your program still does not work. Then the PHP program itself probably has an error on a line that looks like:

    mysql_query( ... ); 

    where ... is some program text.

    If you are a PHP programmer, try adding this snippet just before the semi-colon on every line in every file that has an sql command:

    or die(__FILE__.":".__LINE__."<br>".__FUNCTION__." ".mysql_error()."<br>")

    so that you get something like:

    mysql_query( ... ) 
    or die(__FILE__.":".__LINE__."<br>".__FUNCTION__." ".mysql_error()."<br>");
Please get it working!

You might not know anything at all about PHP programming, but the following lines of text will at least help you tell someone else what the problem might be and may get your PHP programs working without you needing to know any thing complicated at all.

ini_set ("upload_tmp_dir", "tmp"); 

error_reporting (E_ERROR | E_WARNING | E_PARSE | !E_NOTICE);


Almost every PHP program comes with three files that control all the others. Those files are called config.php, index.php and admin.php. At the top of each of those files you will either see <? or <?php.

In each of the three files, copy the lines above and paste them in right under <? or <?php so that the top of the file looks something like:


ini_set ("upload_tmp_dir", "tmp");
error_reporting (E_ERROR | E_WARNING | E_PARSE | !E_NOTICE);


Now upload the three files again, making sure that you remember to set the permissions correctly to 705.

Also, in the folder where you uploaded the PHP files (in the same folder with config.php, index.php and admin.php) create a folder called tmp and make sure that it is world writeable and executable. Its permission index should be 707.

What does this do?

The first line fixes a minor problem with the Force9 configuration. If your PHP program wanted to upload images or other files from someone's computer it would fail without this line.

The second line fixes a problem with some older, badly written programs which would not work if you did not make sure that register_globals was on.

The third line is the one that is most helpful if you need help to get your programs to run or if you want to fix them yourself. It forces PHP to print important warnings and error messages if it finds any problems while it is running the program.

The fourth line tells PHP what sort of errors it should show. If you are having real problems and no errors are showing up but your program still does not work, try deleting the ! in front of E_NOTICE.

The last two lines are actually commented out (disabled). You may find, with some programs, that deleting the // and trying various combinations of On and Off will get your programs to work.

It almost works

If adding those lines seems to get you program to start working, try adding them to every file in the program that ends with .PHP.

I am changing things and nothing is happening

If you are testing new PHP software on your home PC, make sure that your server is running and has access to the web.

If you are testing new PHP software on Force9, make sure that you upload the files after you change them and that the permissions are correctly set after you upload the new file.


This tutorial has been provided very kindly by and specifically Aerig Meginlu (