Don't store resources in your session. They die when the page is finished rendering. Variables you can store in your session. Even objects can be stored in your session. But do not store resources.
I would suggest a couple of things.
1: Use ADOdb instead of just raw my_sql statements. (php.weblogs.com) It has pagination functions that will make your life easier. (It also has a cool caching system, transactional support and a bunch of stuff that takes the hassle out of database programming.
2: If you won't do #1 then the first time you execute the query, spin through the entire recordset and store the records as an array. The array you can save in your session. note if your record set is more than 100 records I would not do this.
Let me know how I may be of service, =C= * Cal Evans * http://www.eicc.com * We take care of your IT, * So you can take care of your business. * * I think inside the sphere.
Michael Lewis wrote:
I have a fairly common problem that I have not been able to find the solution for in the documentation and FAQs. I have to access a MSSQL box from a LAMP box using PHP. That part works fine (thank you freetds.org). I need to display results from user queries 10 at a time with the basic NEXT and BACK logic. I can use the mssql_data_seek function to move amongst the record set. The problem is how do I save the results variable between web page updates? I cannot save the record set variable in my session because it always returns as zero. Consider the following code:
<?php session_start(); include("localsettings.php"); $s = mssql_connect($Server, $User, $Pass) or die("Couldn't connect to SQL Server on $Server"); mssql_select_db($SDB, $s) or die("Couldn't open database $SDB"); $sql="select * from products where prod_id='95038'"; $ress=mssql_query($sql) or die(mssql_get_last_message()); $_SESSION['ress']=$ress; print $ress."\n"; $ress=$_SESSION['ress']; print $ress."\n"; ?>
The first time I print RESS is comes back as RESOURCE OBJECT #12, the second time as 0. When I look in the session file, it is zero.
How can I pass this variable and its contents so they are usable to the next web page?
Thanks in advance.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php