refiking Posted June 8, 2007 Share Posted June 8, 2007 Here's the message I am getting... Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/ctpwebco/public_html/leads/logout.php on line 7 Here's the code: LINE 6: $que = mysql_query("SELECT `analyst_id` FROM `Sessions` WHERE username = '$username'"); LINE 7: while($row = mysql_fetch_assoc($que)){ LINE 8: $analyst_id = $row['analyst_id']; LINE 9: } On the second line (where it starts with while) is my line 7 Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/ Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 try this: <?php $sql = "SELECT `analyst_id` FROM `Sessions` WHERE username = '$username'"; if ($que = mysql_query($sql)) { if (mysql_num_rows($que) > 0) { while ($row = mysql_fetch_assoc($que)) { analyst_id = $row['analyst_id']; } }else{ echo 'not found'; } }else{ echo mysql_error(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270646 Share on other sites More sharing options...
refiking Posted June 8, 2007 Author Share Posted June 8, 2007 That worked! I was looking in the wrong table. BUT........ A new problem arose. I am trying to insert the timestamp for the logout of the same session id in the sessions folder. I have the session id echo'd to make sure it comes up and it does. Here is the code: $dun = date("Y:m:d H:i"); $store = "INSERT INTO Sessions (logout) VALUES ('$dun') WHERE session_id = '$session_id'"; Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270653 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270658 Share on other sites More sharing options...
refiking Posted June 8, 2007 Author Share Posted June 8, 2007 It doesn't get inserted into the table. Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270659 Share on other sites More sharing options...
brissy_matty Posted June 8, 2007 Share Posted June 8, 2007 Do you want to INSERT this or UPDATE ? Looks kinda like UPDATE not INSERT??? Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270666 Share on other sites More sharing options...
refiking Posted June 8, 2007 Author Share Posted June 8, 2007 Got it! Worked perfectly!!! Quote Link to comment https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/#findComment-270668 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.