Most web servers nowadays support PHP and MySQL, but if you are having trouble running PHP code, there's an outside chance your web server doesn't support it. To execute PHP scripts on your website, your web host must support PHP/MySQL. If you are unsure whether you have PHP/MySQL support with your host, you can find out by running a test that involves uploading a simple program and trying to run it.
Testing for PHP Support
- Create a blank text file using NotePad or any other text editor and call it test.php. The .php extension at the end of the file name is critically important. It cannot be .php.html or .php.txt or anything other than .php.
- Put this PHP code in the text file:
- Save the file and upload it to the root of your website on the web server using FTP. The folder may be called public_html or web root or some other name depending on your server, but it is the main folder for your website.
- In a browser, go to www.yoursite.com/test.php. If you see the code as you entered it, then your website cannot run PHP with the current host. If your server supports PHP, you will see a list of all the PHP/SQL properties that are supported by the host.
Among the supported properties listed should be the version of PHP the web server is running. PHP is updated occasionally and each new version typically has better security practices and new features you can take advantage of. If you and your host are not running recent, stable, compatible PHP versions, some problems might be the result. If you are running a more recent stable version that your web server, you may need to find a new web server.