Technology Programming

How to fix it if your variables aren"t passing!

If you pass variables in the URL in PHP4, and then move your scripts to a server running PHP5, you may notice they no longer work. Things such as www.yoursite.com/script.php?color=red in PHP4 would automatically assign $color = red.... how can you make it work in PHP5?
PHP5 is also capable of handling variables in this manor. The difference is that register_globals is turned OFF in php.ini by default in PHP5, and turned ON by default in PHP4.

To make the passed variables work you have two options:

1.) Turn register_globals ON in the php.ini file

or

2.) Use $_GET['var'] In our example of www.yoursite.com/script.php?color=red you would use:

$color = $_GET['color']


Leave a reply