Can anyone tell me why a MYSQL result resource cannot be stored in a session value. For example:
Code: Select all
if(isset($_GET[x])){
$query="SELECT comments FROM table1";
$_SESSION[comments]=mysql_query($query);
}
$comment=mysql_result($_SESSION[comments],0);However if the script is accessed a second time and $_GET[x] is not set the session seems to have failed becauase I get a message that I am using an invalid mysql resource. I know I could use mysql_fetch_row but I am trying to keep the code more efficient by only calling the query once when the script is first read.
Sessions are working elsewhere on the page so it is nothing obvious. It just seems not possible to store the result in a session.
Any ideas?
Thanks,
Rob.