How to fix PHP register_globals errors

If you are using an old version of PHP, it is likely that you have seen errors as follows: PHP Fatal error: Directive ‘register_globals’ is no longer available in PHP in Unknown on line 0

“PHP Fatal error: Directive ‘register_globals’ is no longer available in PHP in Unknown on line 0”

“PHP Fatal error: Directive ‘register_globals’ is deprecated in PHP 5.3 and greater in Unknown on line 0”

Now, register_globals is a php setting which will automatically take the values which were input through any forms to variables. This is a security risk, and hackers can easily guess the values and variables. Hence, from version 5.3 of PHP, this directive has been removed from PHP and is no longer supported.

Solution:

If you get any of the above errors, chances are that you currently reside on a server with PHP version above 5.3 or you were migrated from a server with old PHP to a server with latest PHP. In such cases,  you need to search for a file named php.ini under your domain and comment the following line if found or change the value to 0

 

Sometimes the same will be present in any .htaccess file. Remove the line if found or change the value to off or ‘0’.

You can do the same via cpanel also. Login to your cpanel account using the cpanel login details. Once in the dashboard, go to Software -> Select PHP Version.

 

php2

You will be taken to a page where you can manage the PHP settings. Click on ‘Switch to PHP Options’.

 

php modules

 

It will take you to a page where you can turn register_globals on or off. Choose Off and hit ‘Apply’. Scroll down and click ‘Save’.

 

php11

You can confirm the successful change in value by placing a phpinfo page in your site. Go to the public_html folder of your domain, and create a file named, say info.php, and enter the following contents to it.

 

My domain is copablog.com, now I can access the file as http://copablog.com/info.php. I can see that register_globals shows as off there.

 

register globals settings in phpinfo

 

Now, execute your script again and see if the error vanishes !!!

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *