jumpenjuhosaphat Posted November 4, 2006 Share Posted November 4, 2006 else { $result = mysql_query("SELECT * FROM user"); while($row = mysql_fetch_array($result)) { if($row['id']==$_COOKIE["user"]) { $username=$row['username']; } } include("body.php"); } For some reason the variable $username isn't being set when this code returns true. Sorry if it's an obvious answer, I'm a newbie. Link to comment Share on other sites More sharing options...
jlhaslip Posted November 4, 2006 Share Posted November 4, 2006 Try this: else { $result = mysql_query("SELECT * FROM user"); while($row = mysql_fetch_array($result)) { if($row['id']==$_COOKIE["user"]) {print_r($row);print_r($cookie); $username=$row['username']; } } include("body.php"); } This should print the array values for debugging.*editted*changed the location of the print _r()'s Link to comment Share on other sites More sharing options...
jumpenjuhosaphat Posted November 6, 2006 Author Share Posted November 6, 2006 Okay, I got if figured out. For some reason, on my server, you have to use $_POST["username"] instead of $username. I knew that, but I seemed to have forgotten it when coding this bit of code. Link to comment Share on other sites More sharing options...
skym Posted November 6, 2006 Share Posted November 6, 2006 The reason for that is http://php.net/register_globals It's best to have it disabled. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now