I've set up a site that uses url variables. Its has worked fine. In much of the code I reference the variables by just using $variable and it worked fine. Now all of a sudden none of them work and I have to use $GET['variable'] to retrive them. Any ideas what might of happened?
So if I have 'www.mysite.com?ID=123' and then do <? echo $ID ?> I get nothing. If I do <? echo $GET['ID'] ?> it works.
Read this forum's FAQ on register_globals. Anyway, just use the $_GET superglobal array.
Yeah, someone turned "Register globals" off in your php.ini file, or in .htaccess. Good thing, though, this way it is much safer. I suggest you to rewrite your code to use $GET and $POST superglobals, albeit not directly.
Well now I notice that $REQUEST_URI isn't working? Could these two things be connected. I'm hesitant to change them to $GET because I've already coded many pages the old way and there are hundreds of refences.
Use $_SERVER['REQUEST_URI']. Yes, there is a connection between them, and you should really read the FAQ.
luiddog wrote:I'm hesitant to change them to $GET because I've already coded many pages the old way and there are hundreds of refences.
I'm hesitant to change them to $GET because I've already coded many pages the old way and there are hundreds of refences.
Well if you want you're script to work you've not got much choice
ClarkF1 wrote:Well if you want you're script to work you've not got much choice
Not to mention using the superglobals instead will:
Make your scripts more portable/flexible so that they can withstand server migrations and configuration changes (HINT HINT HINT -- this is the issue you're dealing with)
Avoid security vulnerabilities that have developed from register_global's behavior.
Develop a better coding habit/technique -- I can't imagine why any one would consider relying on a hazardous server configuration as register_globals as a good coding practice.