PHP Frequently Asked Questions


Introduction to PHP

  1. Okay then, just what is PHP, and how can it be used in web development?
  2. Where can I find more resources on PHP?
  3. Why should I use PHP?

Using PHP with your Progressive Networks Account

  1. What version of PHP are you running?
  2. What file extension should I use for my PHP files?
  3. Why does my script put slashes in front of quotes in my form/cookie data?
  4. Are short & ASP style tags enabled?
  5. Is register_globals on?
  6. I need [extension] but you don't have it installed! And I want to change some configuration settings!
  7. Do you have phpMyAdmin pre-installed?
  8. What databases can I use with PHP on f2o?
  9. How do I connect to my MySQL database?
  10. Where do you put a .htaccess file?
  11. How do I set up a PHP mail filter?
  12. Why does fopen() not work?
  13. Why can't I see any PHP errors? I don't know why my script isn't working!

Introduction to PHP


Okay then, just what is PHP, and how can it be used in web development?

It's an Open Source scripting language. Running on the server, it parses a web page dynamically, so that every time a page is requested, the content is generated on the fly.

A better explanation can be found straight from the horse's mouth: php.net and another nice introduction is available from zend.com.

Where can I find more resources on PHP?

Why should I use PHP?

Basically, because it's easy… There are millions of tutorials, resources, code samples, full applications, forums, mailing lists, and other such goodies on the Internet today.

You can start with a basic web page with a single line of PHP code… and learn as much as you like at a pace that suits you. You don't need to know everything about PHP before you can use PHP.

Using PHP with your Progressive Networks account


What version of PHP are you running?

4.3.9 on our PHP4 based f2o free account servers, 5.1.4 on our PHP5 f2o free account servers, and 4.4.2 on our paid account servers.

What file extension should I use for my PHP files?

Your files should have the .php extension to be parsed correctly. However, you can alter this default setting by using an .htaccess file. For example:

AddType application/x-httpd-php .html .plum

would put all files ending in .html and .plum through the php parser.

Why does my script put slashes in front of quotes in my form/cookie data?

Because the magic_quotes_gpc option is turned on for the PHP interpreter. This means that for all get/post/cookie transactions all single-quote('), double quote("), backslash(\) and NULL's are escaped with a backslash automatically. This is desirable if you will be sending these data to a database or another application that doesn't like unbalanced quotes showing up. This is equivalent to performing addslashes() to the string. You can use stripslashes()to remove any slashes in your data before sending to a WWW client.

Are short & ASP style tags enabled?

Short tags are enabled but ASP tags aren't. So:

<? echo "f2o rocks!"; ?>

would work, but:

<% echo "f2o rocks!"; %>

wouldn't. Of course:

<?php echo "f2o rocks!"; ?>

works by default.

Is register_globals on?

No.

I need [extension] but you don't have it installed! And I want to change some configuration settings!

Maybe you don't need the extension installed at compile time… see http://www.php.net/dl. You may also be able to change configuration settings using a .htaccess file or ini_set(). For more information on changing PHP settings, read this article on code portability.

If it still doesn't work, email us and ask if we can install it.

Do you have phpMyAdmin pre-installed?

Yep! See the phpMyAdmin FAQ for more information.

What databases can I use with PHP on f2o.org?

MySQL is the only database enabled by default. When your account was created, a single MySQL database was made for you with the same name as the account. It can be administered through phpMyAdmin.

How do I connect to my MySQL database?

There are two ways to connect. You can either use mysql_connect() or mysql_pconnect().

Example code:

mysql_connect('localhost','YOUR USERNAME','YOUR PASSWORD');
mysql_select_db('YOUR DATABASE NAME');

Your database name is the same as your username.

Where do I put an .htaccess file?

An .htaccess file affects the directory it is in, and all subdirectories of that directory. So if you want your .htaccess file to affect all pages, then put it in the web root directory (e.g. /home/sites/username/www/public_html/).

How do I set up a PHP mail filter?

PHP can be run on the command line, so reading this article will give you instructions on how to set up the mail filter.

Why does fopen() not work?

It will only work on local files for security reasons.

Why can't I see any PHP errors? I don't know why my script isn't working!

display_errors is set to off by default. To turn it on, add the following line to a .htaccess file in your web directory:

php_flag display_errors on

You will also need to set error_reporting to 2047 by adding the following line:

php_value error_reporting 2047

Need More Help?

Progressive Networks has a number of support options in addition to our FAQ's available for our members: