Jump to content

[SOLVED] What Am I Doing Wrong?


refiking

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/54723-solved-what-am-i-doing-wrong/
Share on other sites

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();
}
?>

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'";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.