tmyonline Posted May 6, 2008 Share Posted May 6, 2008 Guys: I'm having this problem that bugs me. Here's a snippet of my code: $contactID = $_GET['id']; echo 'contactID = ' . $contactID; if (isset($_POST['send'])) { echo 'contactID = ' . $contactID; // nothing appeared, wonder why ? ! } The problem is that, somehow, my "$contactID" variable lost its value inside the if statement. It didn't help when I used $_SESSION['contactID'] = $_GET['id'] either. Any ideas ? Thanks. Link to comment https://forums.phpfreaks.com/topic/104408-problem-with-variable/ Share on other sites More sharing options...
GingerRobot Posted May 6, 2008 Share Posted May 6, 2008 What's the actual output from the above? Do you mean that nothing from this line: echo 'contactID = ' . $contactID; // nothing appeared, wonder why ? ! is displayed? In which case, the if statement is evaluating to false. You appear to be using get and post. Perhaps that is the problem? Link to comment https://forums.phpfreaks.com/topic/104408-problem-with-variable/#findComment-534503 Share on other sites More sharing options...
tmyonline Posted May 6, 2008 Author Share Posted May 6, 2008 The actual output is: contactID = So, contactID lost its value. The if statement did evaluate to true because other things (not shown) inside the if statement were processed as expected. As for the potential complication due to using post & get, I just switched everything to "get" but it didn't help. I used $_GET['id'] to get the id value from the url. I'm not sure how that can conflict with the method specified in my form. Link to comment https://forums.phpfreaks.com/topic/104408-problem-with-variable/#findComment-534508 Share on other sites More sharing options...
PFMaBiSmAd Posted May 6, 2008 Share Posted May 6, 2008 If you have a session variable by the same name, it is highly likely that register globals are on and the various variables with the same name are overwriting each other. If not, then you really need to post your actual code. Link to comment https://forums.phpfreaks.com/topic/104408-problem-with-variable/#findComment-534610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.