FlyingIsFun1217 Posted June 25, 2008 Share Posted June 25, 2008 Hey! I've got code that is supposed to get values from a cookie, check a database table to see if the values from the cookie are in there/the same, and proceed if everything worked out. But somehow, it's telling me that they are both null: $cookieUser = $_GET['user']; $cookiePass = $_GET['password']; $sqlUser = 'SELECT user, passmd5 FROM users WHERE user="'.$cookieUser.'"'; $userData = mysql_fetch_array(mysql_query($sqlUser), MYSQL_ASSOC); if($userData['user'] == $cookieUser && $userData['passmd5'] == $cookiePass) { //Success! What it should be doing } I've double-checked that the values in my cookies (both 'user' and 'password') are the same as the values present in the database, and yet still it tells me they are both null-valued. :/ Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/ Share on other sites More sharing options...
whizard Posted June 25, 2008 Share Posted June 25, 2008 Try $cookieUser = $_GET['user']; $cookiePass = $_GET['password']; $sqlUser = 'SELECT user, passmd5 FROM users WHERE user="'.$cookieUser.'"'; $result = mysql_query($sqlUser) or die(mysql_error()); $userData = mysql_fetch_array($result, MYSQL_ASSOC); if($userData['user'] == $cookieUser && $userData['passmd5'] == $cookiePass) { //Success! What it should be doing } that should give an error if the query is wrong. Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/#findComment-574516 Share on other sites More sharing options...
FlyingIsFun1217 Posted June 25, 2008 Author Share Posted June 25, 2008 No; I've already determined that the values I'm getting from the cookies are null (I know this because I have an if($cookieUser == '') conditional). FlyingIsFun1217 Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/#findComment-574521 Share on other sites More sharing options...
DarkWater Posted June 26, 2008 Share Posted June 26, 2008 Use $_COOKIE instead of $_GET. =) Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/#findComment-574538 Share on other sites More sharing options...
FlyingIsFun1217 Posted June 26, 2008 Author Share Posted June 26, 2008 Gah! Der... thanks for continuing to point out my stupid little errors. I think it's time for bed... FlyingIsFun1217 Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/#findComment-574542 Share on other sites More sharing options...
DarkWater Posted June 26, 2008 Share Posted June 26, 2008 Ha, no problem. Stuff like that happens to all of us. xD Link to comment https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/#findComment-574544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.