PHP4 to PHP5

I recently changed from PHP4 to 5. Yeah, I know, took me long enough. Anyway, its on a shared host and they did the change for me. Unfortunately, the PHP stuff I wrote, doesn’t work anymore. I haven’t done anything with PHP in a long time. I’m curious what may have changed that I need to fix my broken pages.

The pages are relatively simple. They call on a MySQL DB for the content and then put that content on the page after you click a link. Currently, I don’t get any errors, but the page doesn’t change when I click on a link to show the content.

I seem to remember something about needing to declare variables when the new PHP came out and I hadn’t done that so I never bothered to update anything.

Any tips would be great



Did you do stuff like $name instead of $_GET[‘name’]? And you don’t get any errors probably because the display or which are turned off. Look for an error log in the same location as the file.

Just to clarify Logic’s post - you shouldn’t use $name (if you are). You should be using $_GET[‘name’] to get values from the URI.

That’s what he meant, but to someone who doesn’t know otherwise it may sound a little ambiguous.

Yes, I just used things like $name. What does $_GET[‘name’] do for me?



One of the PHP documentation’s appendices addresses migrating from PHP 4 to 5.

Without seeing any of your code, though, it’s hard to figure out what your exact problem is.

Basically, using $name instead of $_GET[‘name’] doesn’t work any more. It was a setting called ‘Register Globals’ - there are many articles about it if you wish to look into it further.

But for a quick overview, register globals automatically put values from the superglobal arrays ($_GET, $_POST etc) into the variable namespace - so rather than $_GET[‘something’], people could just use $something.

However, this means that people can practically insert their own values for your variables in scripts - and for security and integrity reasons, register globals was deprecated and is now fully removed.

So, if you want to get values from the url, use $_GET[‘name’], and $_POST[‘name’] for posted variables.

I will give that a try, thanks so much for the information


That did the trick. I went back and reread Kevin’s tutorial about doing PHP and MySQL web sites, where I learned how to do this, and it showed that I needed to add that for my variables. I don’t think it had that back when I read it the first time.

Thank you so much for your help.