Re: [PHP-DB] losing MySQL resource
OK. I finally understand. When I want to save an object across client requests, I need to serialize() that object into a session variable and when I need to use it later I need to unserialize() it into a local variable. If I modify the object, I need to replace the serialized session variable. I've tested this. Or I can let PHP do it ... and that appears to work ... as long as I load the class definitions prior to session_start() ... which appears to conflict with the manual's instruction of using session_start(). And I've tested this. Or I can use an __autoload callback? I don't see where I need to place the __autoload function itself ... and how do I tell PHP to use it ... or is it completely automatic? Thanks, Stan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
Stan wrote: I don't understand the process. When session_start() reconnects to a (the) session, objects saved as $_SESSION variables must be "recreated". To do this requires the class definition. So the class definition must be loaded prior to calling session_start(). Some other languages I've written in had a process called serialization through which objects were saved. And an opposite (deserialization?) process through which objects were restored. To have "persistent" objects requires some way to "save" the objects for the next invocation of the application (PHP in this case). Deserialization necessarily requires the template upon which the original object was built (the class definition). I found http://us.php.net/serialize in the online PHP manual. I also found http://us.php.net/manual/en/language.oop5.autoload.php in the online PHP manual (I have not tried autoload). I simply moved the require_once("class_definitions.inc"); to appear immediately before my session_start(); and everything worked thereafter. When data gets serialized in the session, it only stores the data itself (public/private variables). It does not store the actual class (your methods) and the code that makes it all work. That would just bloat the session and cause other extra headaches. So before the data can be properly loaded, you need the class. http://us.php.net/manual/en/language.oop5.serialization.php explains things a little better I hope. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
I don't understand the process. When session_start() reconnects to a (the) session, objects saved as $_SESSION variables must be "recreated". To do this requires the class definition. So the class definition must be loaded prior to calling session_start(). Some other languages I've written in had a process called serialization through which objects were saved. And an opposite (deserialization?) process through which objects were restored. To have "persistent" objects requires some way to "save" the objects for the next invocation of the application (PHP in this case). Deserialization necessarily requires the template upon which the original object was built (the class definition). I found http://us.php.net/serialize in the online PHP manual. I also found http://us.php.net/manual/en/language.oop5.autoload.php in the online PHP manual (I have not tried autoload). I simply moved the require_once("class_definitions.inc"); to appear immediately before my session_start(); and everything worked thereafter. "Nehemias Duarte" wrote in message news:2a10e35796e8a84fb782111fe5d3b30a036...@pcmex02.hq.aflac.com... I was under the impression that session_start() had to be the FIRST thing ran in the script. Is this incorrect? >>OK. The secret, as has been stated here before, is to load the class definitions BEFORE calling session_start(). Thanks to everyone. ""Andy Shellam (Mailing Lists)"" wrote in message news:3339c510-be08-4426-9265-ba1965a9a...@networkmail.eu... > Hi Stan, > > Are you saving the instance of your class in $_SESSION? > > Class instances can be persisted across sessions, however resources > (i.e. MySQL and other DB connections) cannot. What you need to do, is > every method in your wrapper class that uses the MySQL resource needs > to check if it's a valid resource (is_resource() springs to mind.) > > If it isn't valid, you need to re-create it (using mysql_connect). > > The reason for this is that PHP isn't running between session > requests, so it cannot maintain and monitor the database connection > across requests. > > Andy > > On 9 November2009, at 21:11, Stan wrote: > > > I got as far as creating a class to be the wrapper ... instantiating > > an > > object of that class ... saving the reference in a $_SESSION > > variable ... > > but my object reference seems to be invalid upon the next request > > (in the > > same session) from the client browser. What have I missed? > > > > Thanks, > > Stan > > > > ""Andy Shellam (Mailing Lists)"" wrote in > > message news:fd8200b0-e18a-4afd-8ffc-f51080621...@networkmail.eu... > >> Hi, > >> > >> I got around this by creating a database wrapper class which gets > >> passed the credentials from the app's config file. An instance of > >> the > >> class is created and saved in the session, and every query to the > >> database runs through the class's Query() wrapper method which checks > >> if the connection is alive and valid - if it isn't, it reconnects it > >> before running the query. > >> > >> Andy > >> > >> On 9 November2009, at 16:46, Stan wrote: > >> > >>> How do I make an Object persistant for the duration of a Session? > >>> Thanks, > >>> "Chris" wrote in message news:4AB6B16C. > >>> 8...@gmail.com... > Niel Archer wrote: > >> I'm maintaining a session. I successfully connect to a database > >>> ($DBConnect > >> = mysql_connect()). I save the connection resource in a session > >>> variable > >> ($_SESSION['connection'] = $DBConnect) ... to use in subsequent > >>> queries. It > >> remains valid while the user is on the current page. > >> print_r($_SESSION['connection']) yields 'Resource id #3', for > >> instance. > >> > >> User browses to a new page ... in the same session. > >>> $_SESSION['$DBConnect'] > >> no longer references a valid mysql resource. > >> print_r($_SESSION['connection']) yields '0'. > >> > >> Other "ordinary" values saved in $_SESSION variables remain > >> valid. > >> > >> Is there something special about a mysql resource? > > > > Not about the resource itself, no. PHP closes connections to a Db > > when a > > script ends, unless the connection is persistent, so while the > > resource > > IS saved, the connection to which it refers no longer exists. > > No resources (whether they are persistent or not) can be stored in > the > session. > > http://www.php.net/manual/en/intro.session.php > > The big pink box has more info. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > >>> > >>> > >>> > >>> -- > >>> PHP Database Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >> > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
RE: [PHP-DB] losing MySQL resource
> -Original Message- > From: Nehemias Duarte [mailto:ndua...@aflac.com] > Sent: 11 November 2009 14:25 > To: Stan; php-db@lists.php.net > Subject: RE: [PHP-DB] losing MySQL resource > > I was under the impression that session_start() had to be the FIRST > thing ran in the script. Is this incorrect? Yes. It has to be before any actual *output*, but it would be perfectly valid to have umpteen thousand lines of PHP before session_start() so long as all the output came after it. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] losing MySQL resource
I was under the impression that session_start() had to be the FIRST thing ran in the script. Is this incorrect? >>OK. The secret, as has been stated here before, is to load the class definitions BEFORE calling session_start(). Thanks to everyone. ""Andy Shellam (Mailing Lists)"" wrote in message news:3339c510-be08-4426-9265-ba1965a9a...@networkmail.eu... > Hi Stan, > > Are you saving the instance of your class in $_SESSION? > > Class instances can be persisted across sessions, however resources > (i.e. MySQL and other DB connections) cannot. What you need to do, is > every method in your wrapper class that uses the MySQL resource needs > to check if it's a valid resource (is_resource() springs to mind.) > > If it isn't valid, you need to re-create it (using mysql_connect). > > The reason for this is that PHP isn't running between session > requests, so it cannot maintain and monitor the database connection > across requests. > > Andy > > On 9 November2009, at 21:11, Stan wrote: > > > I got as far as creating a class to be the wrapper ... instantiating > > an > > object of that class ... saving the reference in a $_SESSION > > variable ... > > but my object reference seems to be invalid upon the next request > > (in the > > same session) from the client browser. What have I missed? > > > > Thanks, > > Stan > > > > ""Andy Shellam (Mailing Lists)"" wrote in > > message news:fd8200b0-e18a-4afd-8ffc-f51080621...@networkmail.eu... > >> Hi, > >> > >> I got around this by creating a database wrapper class which gets > >> passed the credentials from the app's config file. An instance of > >> the > >> class is created and saved in the session, and every query to the > >> database runs through the class's Query() wrapper method which checks > >> if the connection is alive and valid - if it isn't, it reconnects it > >> before running the query. > >> > >> Andy > >> > >> On 9 November2009, at 16:46, Stan wrote: > >> > >>> How do I make an Object persistant for the duration of a Session? > >>> Thanks, > >>> "Chris" wrote in message news:4AB6B16C. > >>> 8...@gmail.com... > Niel Archer wrote: > >> I'm maintaining a session. I successfully connect to a database > >>> ($DBConnect > >> = mysql_connect()). I save the connection resource in a session > >>> variable > >> ($_SESSION['connection'] = $DBConnect) ... to use in subsequent > >>> queries. It > >> remains valid while the user is on the current page. > >> print_r($_SESSION['connection']) yields 'Resource id #3', for > >> instance. > >> > >> User browses to a new page ... in the same session. > >>> $_SESSION['$DBConnect'] > >> no longer references a valid mysql resource. > >> print_r($_SESSION['connection']) yields '0'. > >> > >> Other "ordinary" values saved in $_SESSION variables remain > >> valid. > >> > >> Is there something special about a mysql resource? > > > > Not about the resource itself, no. PHP closes connections to a Db > > when a > > script ends, unless the connection is persistent, so while the > > resource > > IS saved, the connection to which it refers no longer exists. > > No resources (whether they are persistent or not) can be stored in > the > session. > > http://www.php.net/manual/en/intro.session.php > > The big pink box has more info. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > >>> > >>> > >>> > >>> -- > >>> PHP Database Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >> > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Confidentiality Notice: This e-mail and any attachments may contain confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, any distribution, copying, or use of this e-mail or its attachments is prohibited. If you received this message in error, please notify the sender immediately by e-mail and delete this message and any copies. Thank you. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
OK. The secret, as has been stated here before, is to load the class definitions BEFORE calling session_start(). Thanks to everyone. ""Andy Shellam (Mailing Lists)"" wrote in message news:3339c510-be08-4426-9265-ba1965a9a...@networkmail.eu... > Hi Stan, > > Are you saving the instance of your class in $_SESSION? > > Class instances can be persisted across sessions, however resources > (i.e. MySQL and other DB connections) cannot. What you need to do, is > every method in your wrapper class that uses the MySQL resource needs > to check if it's a valid resource (is_resource() springs to mind.) > > If it isn't valid, you need to re-create it (using mysql_connect). > > The reason for this is that PHP isn't running between session > requests, so it cannot maintain and monitor the database connection > across requests. > > Andy > > On 9 November2009, at 21:11, Stan wrote: > > > I got as far as creating a class to be the wrapper ... instantiating > > an > > object of that class ... saving the reference in a $_SESSION > > variable ... > > but my object reference seems to be invalid upon the next request > > (in the > > same session) from the client browser. What have I missed? > > > > Thanks, > > Stan > > > > ""Andy Shellam (Mailing Lists)"" wrote in > > message news:fd8200b0-e18a-4afd-8ffc-f51080621...@networkmail.eu... > >> Hi, > >> > >> I got around this by creating a database wrapper class which gets > >> passed the credentials from the app's config file. An instance of > >> the > >> class is created and saved in the session, and every query to the > >> database runs through the class's Query() wrapper method which checks > >> if the connection is alive and valid - if it isn't, it reconnects it > >> before running the query. > >> > >> Andy > >> > >> On 9 November2009, at 16:46, Stan wrote: > >> > >>> How do I make an Object persistant for the duration of a Session? > >>> Thanks, > >>> "Chris" wrote in message news:4AB6B16C. > >>> 8...@gmail.com... > Niel Archer wrote: > >> I'm maintaining a session. I successfully connect to a database > >>> ($DBConnect > >> = mysql_connect()). I save the connection resource in a session > >>> variable > >> ($_SESSION['connection'] = $DBConnect) ... to use in subsequent > >>> queries. It > >> remains valid while the user is on the current page. > >> print_r($_SESSION['connection']) yields 'Resource id #3', for > >> instance. > >> > >> User browses to a new page ... in the same session. > >>> $_SESSION['$DBConnect'] > >> no longer references a valid mysql resource. > >> print_r($_SESSION['connection']) yields '0'. > >> > >> Other "ordinary" values saved in $_SESSION variables remain > >> valid. > >> > >> Is there something special about a mysql resource? > > > > Not about the resource itself, no. PHP closes connections to a Db > > when a > > script ends, unless the connection is persistent, so while the > > resource > > IS saved, the connection to which it refers no longer exists. > > No resources (whether they are persistent or not) can be stored in > the > session. > > http://www.php.net/manual/en/intro.session.php > > The big pink box has more info. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > >>> > >>> > >>> > >>> -- > >>> PHP Database Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >> > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
Hi Stan, Are you saving the instance of your class in $_SESSION? Class instances can be persisted across sessions, however resources (i.e. MySQL and other DB connections) cannot. What you need to do, is every method in your wrapper class that uses the MySQL resource needs to check if it's a valid resource (is_resource() springs to mind.) If it isn't valid, you need to re-create it (using mysql_connect). The reason for this is that PHP isn't running between session requests, so it cannot maintain and monitor the database connection across requests. Andy On 9 November2009, at 21:11, Stan wrote: I got as far as creating a class to be the wrapper ... instantiating an object of that class ... saving the reference in a $_SESSION variable ... but my object reference seems to be invalid upon the next request (in the same session) from the client browser. What have I missed? Thanks, Stan ""Andy Shellam (Mailing Lists)"" wrote in message news:fd8200b0-e18a-4afd-8ffc-f51080621...@networkmail.eu... Hi, I got around this by creating a database wrapper class which gets passed the credentials from the app's config file. An instance of the class is created and saved in the session, and every query to the database runs through the class's Query() wrapper method which checks if the connection is alive and valid - if it isn't, it reconnects it before running the query. Andy On 9 November2009, at 16:46, Stan wrote: How do I make an Object persistant for the duration of a Session? Thanks, "Chris" wrote in message news:4AB6B16C. 8...@gmail.com... Niel Archer wrote: I'm maintaining a session. I successfully connect to a database ($DBConnect = mysql_connect()). I save the connection resource in a session variable ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It remains valid while the user is on the current page. print_r($_SESSION['connection']) yields 'Resource id #3', for instance. User browses to a new page ... in the same session. $_SESSION['$DBConnect'] no longer references a valid mysql resource. print_r($_SESSION['connection']) yields '0'. Other "ordinary" values saved in $_SESSION variables remain valid. Is there something special about a mysql resource? Not about the resource itself, no. PHP closes connections to a Db when a script ends, unless the connection is persistent, so while the resource IS saved, the connection to which it refers no longer exists. No resources (whether they are persistent or not) can be stored in the session. http://www.php.net/manual/en/intro.session.php The big pink box has more info. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
I got as far as creating a class to be the wrapper ... instantiating an object of that class ... saving the reference in a $_SESSION variable ... but my object reference seems to be invalid upon the next request (in the same session) from the client browser. What have I missed? Thanks, Stan ""Andy Shellam (Mailing Lists)"" wrote in message news:fd8200b0-e18a-4afd-8ffc-f51080621...@networkmail.eu... > Hi, > > I got around this by creating a database wrapper class which gets > passed the credentials from the app's config file. An instance of the > class is created and saved in the session, and every query to the > database runs through the class's Query() wrapper method which checks > if the connection is alive and valid - if it isn't, it reconnects it > before running the query. > > Andy > > On 9 November2009, at 16:46, Stan wrote: > > > How do I make an Object persistant for the duration of a Session? > > Thanks, > > "Chris" wrote in message news:4AB6B16C. > > 8...@gmail.com... > >> Niel Archer wrote: > I'm maintaining a session. I successfully connect to a database > > ($DBConnect > = mysql_connect()). I save the connection resource in a session > > variable > ($_SESSION['connection'] = $DBConnect) ... to use in subsequent > > queries. It > remains valid while the user is on the current page. > print_r($_SESSION['connection']) yields 'Resource id #3', for > instance. > > User browses to a new page ... in the same session. > > $_SESSION['$DBConnect'] > no longer references a valid mysql resource. > print_r($_SESSION['connection']) yields '0'. > > Other "ordinary" values saved in $_SESSION variables remain valid. > > Is there something special about a mysql resource? > >>> > >>> Not about the resource itself, no. PHP closes connections to a Db > >>> when a > >>> script ends, unless the connection is persistent, so while the > >>> resource > >>> IS saved, the connection to which it refers no longer exists. > >> > >> No resources (whether they are persistent or not) can be stored in > >> the > >> session. > >> > >> http://www.php.net/manual/en/intro.session.php > >> > >> The big pink box has more info. > >> > >> -- > >> Postgresql & php tutorials > >> http://www.designmagick.com/ > >> > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
Hi, I got around this by creating a database wrapper class which gets passed the credentials from the app's config file. An instance of the class is created and saved in the session, and every query to the database runs through the class's Query() wrapper method which checks if the connection is alive and valid - if it isn't, it reconnects it before running the query. Andy On 9 November2009, at 16:46, Stan wrote: How do I make an Object persistant for the duration of a Session? Thanks, "Chris" wrote in message news:4AB6B16C. 8...@gmail.com... Niel Archer wrote: I'm maintaining a session. I successfully connect to a database ($DBConnect = mysql_connect()). I save the connection resource in a session variable ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It remains valid while the user is on the current page. print_r($_SESSION['connection']) yields 'Resource id #3', for instance. User browses to a new page ... in the same session. $_SESSION['$DBConnect'] no longer references a valid mysql resource. print_r($_SESSION['connection']) yields '0'. Other "ordinary" values saved in $_SESSION variables remain valid. Is there something special about a mysql resource? Not about the resource itself, no. PHP closes connections to a Db when a script ends, unless the connection is persistent, so while the resource IS saved, the connection to which it refers no longer exists. No resources (whether they are persistent or not) can be stored in the session. http://www.php.net/manual/en/intro.session.php The big pink box has more info. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
How do I make an Object persistant for the duration of a Session? Thanks, "Chris" wrote in message news:4ab6b16...@gmail.com... > Niel Archer wrote: > >> I'm maintaining a session. I successfully connect to a database ($DBConnect > >> = mysql_connect()). I save the connection resource in a session variable > >> ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It > >> remains valid while the user is on the current page. > >> print_r($_SESSION['connection']) yields 'Resource id #3', for instance. > >> > >> User browses to a new page ... in the same session. $_SESSION['$DBConnect'] > >> no longer references a valid mysql resource. > >> print_r($_SESSION['connection']) yields '0'. > >> > >> Other "ordinary" values saved in $_SESSION variables remain valid. > >> > >> Is there something special about a mysql resource? > > > > Not about the resource itself, no. PHP closes connections to a Db when a > > script ends, unless the connection is persistent, so while the resource > > IS saved, the connection to which it refers no longer exists. > > No resources (whether they are persistent or not) can be stored in the > session. > > http://www.php.net/manual/en/intro.session.php > > The big pink box has more info. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
Niel Archer wrote: I'm maintaining a session. I successfully connect to a database ($DBConnect = mysql_connect()). I save the connection resource in a session variable ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It remains valid while the user is on the current page. print_r($_SESSION['connection']) yields 'Resource id #3', for instance. User browses to a new page ... in the same session. $_SESSION['$DBConnect'] no longer references a valid mysql resource. print_r($_SESSION['connection']) yields '0'. Other "ordinary" values saved in $_SESSION variables remain valid. Is there something special about a mysql resource? Not about the resource itself, no. PHP closes connections to a Db when a script ends, unless the connection is persistent, so while the resource IS saved, the connection to which it refers no longer exists. No resources (whether they are persistent or not) can be stored in the session. http://www.php.net/manual/en/intro.session.php The big pink box has more info. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
Thanks. "Niel Archer" wrote in message news:20090919121842.b95b.a5cb2...@chance.now... > > I'm maintaining a session. I successfully connect to a database ($DBConnect > > = mysql_connect()). I save the connection resource in a session variable > > ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It > > remains valid while the user is on the current page. > > print_r($_SESSION['connection']) yields 'Resource id #3', for instance. > > > > User browses to a new page ... in the same session. $_SESSION['$DBConnect'] > > no longer references a valid mysql resource. > > print_r($_SESSION['connection']) yields '0'. > > > > Other "ordinary" values saved in $_SESSION variables remain valid. > > > > Is there something special about a mysql resource? > > Not about the resource itself, no. PHP closes connections to a Db when a > script ends, unless the connection is persistent, so while the resource > IS saved, the connection to which it refers no longer exists. > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > Niel Archer > niel.archer (at) blueyonder.co.uk > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] losing MySQL resource
> I'm maintaining a session. I successfully connect to a database ($DBConnect > = mysql_connect()). I save the connection resource in a session variable > ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries. It > remains valid while the user is on the current page. > print_r($_SESSION['connection']) yields 'Resource id #3', for instance. > > User browses to a new page ... in the same session. $_SESSION['$DBConnect'] > no longer references a valid mysql resource. > print_r($_SESSION['connection']) yields '0'. > > Other "ordinary" values saved in $_SESSION variables remain valid. > > Is there something special about a mysql resource? Not about the resource itself, no. PHP closes connections to a Db when a script ends, unless the connection is persistent, so while the resource IS saved, the connection to which it refers no longer exists. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Niel Archer niel.archer (at) blueyonder.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php