Hi, Wednesday, December 17, 2003, 12:15:24 PM, you wrote: ML> I posted this on the PHP-DB list and then realized it was a more general ML> question about PHP than DB so I am posting it here also hoping someone can ML> help.
ML> I have a fairly common problem that I have not been able to find the ML> solution for in the documentation and FAQs. I have to access a MSSQL box ML> from a LAMP box using PHP. That part works fine (thank you freetds.org). I ML> need to display results from user queries 10 at a time with the basic NEXT ML> and BACK logic. I can use the mssql_data_seek function to move amongst the ML> record set. The problem is how do I save the results variable between web ML> page updates? I cannot save the record set variable in my session because it ML> always returns as zero. Consider the following code: ML> <?php ML> session_start(); ML> include("localsettings.php"); ML> $s = mssql_connect($Server, $User, $Pass) or die("Couldn't connect to SQL ML> Server on $Server"); ML> mssql_select_db($SDB, $s) or die("Couldn't open database $SDB"); ML> $sql="select * from products where prod_id='95038'"; ML> $ress=mssql_query($sql) or die(mssql_get_last_message()); ML> $_SESSION['ress']=$ress; ML> print $ress."\n"; ML> $ress=$_SESSION['ress']; ML> print $ress."\n"; ?>> ML> The first time I print RESS is comes back as RESOURCE OBJECT #12, the second ML> time as 0. When I look in the session file, it is zero. ML> Help! ML> How can I pass this variable and its contents so they are usable to the next ML> web page? ML> Thanks in advance. ML> Michael The connection to the database will close at the end of the request so your resource will no longer be valid. You will have to rerun the query again. If there is some way to identify each row then change the query to always get an id that is higher than the last one you read (that is the one you save in the session) a bit like this $last_id =0; if(isset($_SESSION['last_id'])) $last_id = $_SESSION['last_id']; $sql = "SELECT * FROM table WHERE id > '$last_id' order by id"; //do query $x =0 while(get_reults && $x < 10){ //do whatever $x++; } $_SESSION['last_id'] = id; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php