Do you have any FAQs on PHP, cgi, mySQL and scripts? Print

  • 28

Can I place a PHP script in any directory I choose?

Yes, PHP scripts do not have to reside in a particular directory and will run anywhere on your account, as long as the file permissions are correct?

What version of PHP do you run?

You can find out the version of different programs by logging into your Control Panel. Select the Web Diagnostics section and then select ‘Paths and Versions’.

Whats the maximum file upload and timeout set for PHP?

The maximum size at present is set at 5MB and the timeout is 30 seconds.

Do you support Zend Optimiser?

After a recent update, Zend Optimiser is now available for use on our servers, though optimised code is not supported by us directly.

What is the path to ImageMagick?

The path for that is /usr/bin/convert.

How can I upload my MySQL database?

Method 1 – phpMyAdmin You may use phpMyAdmin to load your database by pasting the SQL script and execute it.

1. Login to phpMyAdmin with a MySQL user that has been given DBA rights to the MySQL database you wish to load.

2. Then click on the SQL tab.

3. Paste the SQL script content into the text area, and click Go. If the SQL script contains a lot of data, you might still get away with this by pasting it bit by bit. If the data is simply too large, see the next section.

Method 2 - mysql command line client Due to the limitations imposed by PHP, phpMyAdmin is unable to load a large MySQL dump data. You can upload the MySQL dump file created by mysqldump --opt -Q dbname to your home directory, and then execute the MySQL client to load it.

This requires you to have SSH Access. To load your sql dump using MySQL, you can use the following command: mysql -h mysqlhost -u mysqlusername -p databasename < dumpfile or cat dumpfile | mysql -h mysqlhost -u mysqlusername -p databasename Where: mysqlhost - The name of the server where your MySQL database is located. You can find this out from the Control Panel in the MySQL Database area. mysqlusername - Your MySQL User name as created through the Control Panel. This User must have DBA rights to the database so it can create / drop tables. databasename - This is the name of your database dumpfile - The file created by mysqldump

I have created an include file that contains a username and password for a database. How do I prevent people from accessing that file directly?

 Protecting PHP Includes In order to create a PHP file that is inaccessible from the WWW, please follow these instructions.

1) Create a directory within your public_html directory

2) Password protect the directory

3) Add the files that you do not want to be accessible to the protected directory As PHP accesses files internally, it ignores password protected directories. However, if anyone tried to directly access those files from an external source, they would be prompted for a username and password.

What is PHP?

Self-referentially short for PHP: Hypertext Preprocessor, an open source, server-side, HTML embedded scripting language used to create dynamic Web pages. In an HTML document, PHP script (similar syntax to that of Perl or C ) is enclosed within special PHP tags. Because PHP is embedded within tags, the author can jump between HTML and PHP (similar to ASP and Cold Fusion) instead of having to rely on heavy amounts of code to output HTML. And, because PHP is executed on the server, the client cannot view the PHP code. PHP can perform any task that any CGI program can do, but its strength lies in its compatibility with many types of databases. PHP is fully supported on all hosting accounts. For more information about PHP we suggest looking at

How do I query a MySQL database from a PHP script?

Use the following outline to connect and begin querying the MySQL server from within your PHP scripts. Remember that you cannot connect to your databases remotely for security reasons; you can only connect from localhost.

1. Connect to the MySQL Server Use the following statement to connect to the database server. Substitute the username and password for those that have been created in the MyAdmin interface and have given adequate permissions to this database. mysql_connect('localhost','USERNAME','PASSWORD');

2. Select Your Database Use the following statement to select the database you wish to connect to. Make sure you substitute your database name. mysql_select_db("DATABASENAME");

3. Executing A Query You are now ready to execute your queries. Most problems that arise with your scripts will be caused by incorrect permission settings.

What file extensions can run PHP?

The following file extensions will all work for PHP files: .php .php3 .php4 A custom filetype isn't being recognised, how can I make sure it is? You can force this through using a '.htaccess' file. Remember that the directives inside an '.htaccess' file apply not only to the directory in which the '.htaccess' file is placed, but also to its subdirectories too. To override the default file associations and reorient the mapping of given file extensions to user-specificied handlers, the AddHandler directive can be invoked Suppose it is desired that all files with the extension of '.cat' be recognized and processed by the server as a cgi program - AddHandler cgi-script .cat Similarly, to remap the PHP content-type to files ending in, '.rip', use - AddType application/x-httpd-php .rip If you think a given MIME type is worthy of server-wide recognition, please let us know.

Can I override php.ini settings?

Some variables in the php.ini file can be overwritten, you can do this creating a php.ini file in the directory you want to use, with the following command: variable_name = variable_value We cannot however offer any support for this should it not produce the desired results for your scripts.

How do I backup my MySQL database?

Backing up your MySQL database can be done in several ways:

1. Using phpMyAdmin web interface

2. Using command line through shell access Using phpMyAdmin Log into your Extend Control Panel and click on Account Utilities. Click to configure MySQL Databases and choose the database that you want to manage. This will start phpMyAdmin. PhpMyAdmin can export your entire database by selecting the "Export" page.

1. Select all tables

2. Select "Structure and data"

3. Select "Add drop table"

4. Select "Enclose table and field names with backquotes"

5. Select "Save as file"

6. Then click "Go" button You will be prompted to save the dump file on your computer. Using mysql command line tools To use MySQL command line tools, you would need to have shell access on Unix hosting. You can perform backup using the following command: mysqldump -h servername -u username -p --opt -Q databasename > databasedump.sql To backup and compress your dump file: mysqldump -h servername -u username -p --opt -Q databasename | gzip > databasedump.sql.gz The commands above will create the dump file in your current directory. You can download this backup file using scp or ftp for your archival purposes.

I need a specific PHP or Perl Module which isn't shown in the Web Diagnostics section of my Extend Control Panel. Can this be added?

In the first instance, please verify that the module you require isn't already installed. To see a list of the available modules, go to your Extend Control Panel and select Web Diagnostics. Under that section you can then select ‘Module List’ which will list all the PHP and Perl modules available on your server. If the module you require isn't in place, please raise a ticket to our support team with your specific requirements, which it may not be possible to add certain modules in some circumstances as it may have an adverse effect on the module and other software already in place.

What PHP or Perl modules are installed?

Simply log into your Extend Control Panel and select Web Diagnostics. Under that section you can then select ‘Module List’ which will list all the PHP and Perl modules available on your server.

Is PHP a CGI or Apache module?

PHP runs as a cgi – this is because it is more secure than running it as an Apache module (if it runs as an Apache module PHP runs as the same user with the same rights as Apache).

What are the correct file permissions for a PHP script?

To avoid any problems, you should set your PHP scripts file permissions to 644, or user read and write, group and world read.

Can you set "register_globals" to ON in PHP for me?

Such a global change to the php.ini config is a well known security risk and affects all other customers and isn't something we'd consider doing. However you can set that and any other variable using the method below. You can create your own php.ini file inside whatever sub-directory your script is in. You can then determine the exact behaviour for your PHP scripts yourself. There's a lot of documentation on how to use the various configuration features inside php.ini online at

How do I connect to my MySQL database?

Once you have created a database using your Control Panel you will be able to manage it using phpMyAdmin. Once the database is created you’ll see a new option in the MySQL section of your Extend Control Panel. You’ll now be able to Edit/Manage/Delete your databases. To manage your database all you need to do is to click on the ‘Now’ link and phpMyAdmin will start.

What are the maximum number of simultaneous connections for MySQL Databases?

The maximum number of simultaneous connections for MySQL Databases are 25 - you may encounter connection error messages if you exceed this number.  Please ensure any scripts that are no longer required are closed to avoid any such errors.

My cgi/asp/php script is giving an error when trying to write to a file.

This is almost certainly down to incorrect permissions on your script or file. Please see the following information on how to set permissions on files: Doing a CHMOD (changing a file's permissions) is the setting of access privileges for a file. This tutorial shows the process in one of the most common FTP applications called WS_FTP but the process is very similar with other ftp clients.

Only Perl scripts need to have permissions changed to run. First connect to your hosting via FTP using the settings provided in your setup email. Click on the "public_html" directory to open the area where your website is placed. Next click on the cgi-bin directory and right-click on the file you would like to set permissions for. The right-click menu is then displayed, and by clicking the "CHMOD" option we get to the main part of doing a CHMOD. The new menu that appears has three columns - Owner, Group, and Other. Each column has three checkboxes below them - Read, Write, and Execute. In the "Owner" column, check all three boxes. In the "Group" column check the first and third checkboxes. In the "Other" column, check the first and third boxes. Finally, click "OK" to complete the CHMOD. Test your script again by calling it from your web browser. Everything should work correctly, but if you are still seeing an Error 500 Server Error then it is not because of your permissions.

Was this answer helpful?

« Back