A few days ago I transfered a domain to dreamhost. I moved a directory of files to the new domain and everything was fine. When I viewed the pages in the new domain, I noticed something was wrong. Some of my pages have data that is passed to them through variables in the URL. For example, I have a page like www.mydomain.com/filename.php?value=test. If I try to echo $value in the page, nothing happens. It’s like ?value=test isn’t even there.
I’m completely stumped as to why this is happening.
One easy way to “test” to see if this is, indeed, responsible for your error, is to set your domain to use PHP4 from the Control Panel > Domains -> Manage Domains screen. Just click the “edit” link under the “Web Hosting” column in the row for your domain, change the radio button to PHP 4x, and “save” the changes. You can always change it back to PHP5 if you wish at a later time.
If the register_globals setting was the problem, then your pages should work under PHP4. If that is the case, you can either modify your code to work without the register_globals setting being “ON” (best choice, and some info on how to do that is in that wiki article I linked above), or just run your script(s) under PHP4.
If you particularly want to use php5, then you can do this at the top of your page:
$value = $_GET["value"];
Do that for each querystring value you’ve got and your code should work fine. You can actually use that method whilst still using PHP 4, it’ll just be redeclaring what you’re already declared.
If you’re using a form to post variables, then replace $_GET[“value”] with $_POST[“value”].
You can use $_REQUEST[“value”] to cover both eventualities, but i like to be specific so that the server gets what i’m expecting it to.
Or, if you’re not concerned about security, which you should be, you can do this:
This will put all POST (forms that have the method attribute set to "post")
and GET (url variables and forms that don't have the method attribute set to "post") variables
into the current scope
Visit me, please… www.theraven7.com