MishieMoo Posted December 2, 2007 Share Posted December 2, 2007 Okay so I have a memberlist on my site. I've been able to display all the information correctly, but I've run into a little snag. The part of my code that I'm having a problem with is this $uid = mysql_query("SELECT * FROM users WHERE id = '$id'"); //Searches the database for the user with the id specified in the url if (mysql_num_rows($uid) !=0) {$u = mysql_fetch_array($uid); extract($u); echo '<strong>Viewing '.$username.'´s Profile </strong><br />'; echo 'Nickname: '.$name.'<br />'; echo 'Email: '.$email.'<br> Last Login: '.$lastlogin.'<br> Joined: '.$signup.'<br>.'; $back = $id - 1; //The id in the url minus 1 $forward = $id + 1; //The id in the url plus 1 print '<a href="/members.php?id=$back">Last:</a>'; //A link to the previous profile print '<a href="/members.php?id=$forward">Next</a>';//A link to the next profile } If you notice I have a mysql_query that's selecting * from my user table. When this code is on the profile, and I visit another person's profile from my own, I become logged in as them with everything changing except the user id. But when I change it so that I'm selecting just the information from the table that's being displayed (in this case username, name, email, last login, and signup date) that doesn't happen. My question is, how does selecting all from the database change the variables that I'm logged in with. I use sessions to establish username and rank, which are the two major things changing right now. How or why are those two variables being changed? I know I can do it the other way, but after the profile's are finished they'll have quite a bit of information on them and I'd like to use the * instead of listing out every column of the table. If someone could give me a clue it would be lovely xD Quote Link to comment Share on other sites More sharing options...
Barand Posted December 2, 2007 Share Posted December 2, 2007 Have you got register_globals set ON in your php.ini file? Are you using session_register or $_SESSION global? Is you session variable the same name as that created when you "extract($u)"? Quote Link to comment Share on other sites More sharing options...
MishieMoo Posted December 2, 2007 Author Share Posted December 2, 2007 Register_globals are off. I'm using $_SESSION globals. And I'm not exactly sure what you mean by the names. I've tried this using $u[username] instead of $username and it's still the same output. If you mean that $u is the same variable that I'm using when I register the $_SESSION then no. That's $user_info. Quote Link to comment Share on other sites More sharing options...
MishieMoo Posted December 3, 2007 Author Share Posted December 3, 2007 ...bump for the night. Quote Link to comment Share on other sites More sharing options...
MishieMoo Posted December 3, 2007 Author Share Posted December 3, 2007 ...Bump. I really need help with this! Quote Link to comment 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.