SirChick Posted October 10, 2007 Share Posted October 10, 2007 I have a session which bounce's out the user if the session doesn't contain their UserID. I aint even changed the code in any way the only substantial change i have done is copy n pasted the script to a different pc and now it won't work at this pc. But it still does on the other computer even though they are 100% the same. This is the session check: $GetUserID = mysql_query("SELECT * FROM userregistration WHERE UserID='{$_SESSION['Current_User']}'"); // Fetch the row from the database if (!($row = mysql_fetch_assoc($GetUserID))) { echo "User not found!"; exit; echo mysql_error(); } The result gives: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\include.php on line 41 User not found! Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/ Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 Is the variable defined, or better yet, have a value? Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366507 Share on other sites More sharing options...
SirChick Posted October 10, 2007 Author Share Posted October 10, 2007 $_SESSION['Current_User'] when echo'd = 1 which is correct Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366509 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 or die(mysql_error()); error reporting is good Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366510 Share on other sites More sharing options...
SirChick Posted October 10, 2007 Author Share Posted October 10, 2007 Doesn't give any error for that. I echo'd the query which gives: Resource id #5 If that means anything? Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366513 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 if (!isset($row = mysql_fetch_assoc($GetUserID))) { echo "User not found!"; exit; echo mysql_error(); Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366515 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 -tries to decipher darkfreaks's post- Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366516 Share on other sites More sharing options...
SirChick Posted October 10, 2007 Author Share Posted October 10, 2007 if (!isset($row = mysql_fetch_assoc($GetUserID))) { echo "User not found!"; exit; echo mysql_error(); =/ whats this do exactly ? never seen something like that before. Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366519 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 Use mysql_num_rows Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366521 Share on other sites More sharing options...
darkfreaks Posted October 11, 2007 Share Posted October 11, 2007 if (!isset($row = mysql_fetch_assoc($GetUserID))) { echo "User not found!"; exit; echo mysql_error(); =/ whats this do exactly ? never seen something like that before. if the row isnt set it errors else it displays the userid Quote Link to comment https://forums.phpfreaks.com/topic/72686-session-check-is-not-working/#findComment-366633 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.