ejarnutowski Posted December 11, 2009 Share Posted December 11, 2009 Hi guys/gals, I have a variable $id that i'm declaring from a $_GET ( $id = $_GET['id'] ) and for some reason that $id variable still holds a value in other pages. register globals is off and i don't think im declaring it as a global. any idea what would make this happen? my code is below. if i go to another page and print out the $id variable, it contains the value from this page for some reason. <?php session_start(); include '_private/dbconnect.php'; //connecting to db //if there's no id to get from the url, redirect to index.php if (!isset($_GET['id'])){ header("location:index.php"); exit(); } //query the users table to grab the row with the posted user id and store some data into variables $id=$_GET['id']; $query=mysql_query("SELECT * FROM users WHERE id='$id'"); $fetch=mysql_fetch_array($query); $first_name = ucwords($fetch['first_name']); $last_name = ucwords($fetch['last_name']); $nh_city = ucwords($fetch['nh_city']); $nh_state = strtoupper($fetch['nh_state']); $current_votes = $fetch['current_votes']; //query the users table to get the number of current candidates $query=mysql_query("SELECT id FROM users WHERE acct_status !='disabled'"); $fetch=mysql_num_rows($query); $total_girls = $fetch; //query the users table and run a small loop to get the rank $query=mysql_query("SELECT id, current_votes FROM users WHERE acct_status !='disabled' ORDER BY current_votes DESC"); $stop = "go"; $count = "0"; while ($stop != "stop"){ $count = $count + 1; $fetch=mysql_fetch_array($query); if ($fetch['id'] == $id){ $stop = "stop"; $rank = $count; } } //query the period table to get the start and end dates of this voting period $query=mysql_query("SELECT datetime_start, datetime_end FROM period WHERE period='current'"); $fetch=mysql_fetch_array($query); $period_start = substr($fetch['datetime_start'], 5, 2) . "/" . substr($fetch['datetime_start'], 8, 2) . "/" . substr($fetch['datetime_start'], 0, 4); $period_end = substr($fetch['datetime_end'], 5, 2) . "/" . substr($fetch['datetime_end'], 8, 2) . "/" . substr($fetch['datetime_end'], 0, 4); //query the photos table to get the primary photo information $query = mysql_query("SELECT file_name, file_location FROM photos WHERE user_id='$id' and profile_photo='yes'"); $fetch = mysql_fetch_array($query); $file_location = $fetch['file_location']; $file_name = $fetch['file_name']; //if there's no profile photo, a default picture is displayed if (mysql_num_rows($query) < 1){ $no_photos = "true"; $file_location = "images/"; $file_name = "default_profile_picture.jpg"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/184800-why-a-normal-variable-keeps-its-value-on-another-page/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 11, 2009 Share Posted December 11, 2009 What does a phpinfo() statement show for the actual register_globals setting? Quote Link to comment https://forums.phpfreaks.com/topic/184800-why-a-normal-variable-keeps-its-value-on-another-page/#findComment-975595 Share on other sites More sharing options...
ejarnutowski Posted December 11, 2009 Author Share Posted December 11, 2009 Hi, Thanks for the input, but i'm fairly familiar with the language and have been coding with it for a few years. great idea to check the phpinfo though. before your post, i checked this setting through the control panel of my hosting account and register globals is set OFF but it's showing as turned on using phpinfo. i'm contacting the hosting account now. thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/184800-why-a-normal-variable-keeps-its-value-on-another-page/#findComment-975607 Share on other sites More sharing options...
teamatomic Posted December 11, 2009 Share Posted December 11, 2009 Is it possible that whatever is building your links is keeping the $_GET in the url? HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/184800-why-a-normal-variable-keeps-its-value-on-another-page/#findComment-975637 Share on other sites More sharing options...
ejarnutowski Posted December 11, 2009 Author Share Posted December 11, 2009 No, it's a server problem from my hosting company. they're checking into it. Quote Link to comment https://forums.phpfreaks.com/topic/184800-why-a-normal-variable-keeps-its-value-on-another-page/#findComment-975695 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.