Re: Sessions + Connection Object?

From: Date: Fri, 03 Nov 2000 17:48:44 +0000
Subject: Re: Sessions + Connection Object?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23597@lists.php.net to get a copy of this message
You can't pass along a connection identifier. If you were to look at it you would see that $db is simply an integer which refers to a connection. This connection is tied to the httpd process that it was established from. Passing this integer to another request which will more than likely be served up by a different httpd process makes no sense. -Rasmus On Fri, 3 Nov 2000, Daryl Chance wrote: > Hi, > > I'm working on changing a site around that I am currently tinkering with > as a learning experience. The site uses MySQL and PHP4. Currently, > everytime I load a page and do a select from the database, it logs in > and selects the database. I would like to be able to store the connection > in a session and do something like: > (code might not be perfect, but its as close as i can remember atm) > > if (!session_is_registered("db")) > { > echo "Created connection"; > session_register("db"); // can ref as global now by $db > $db = mysql_connect....; > { > else > echo "Using Cached Connection"; > > this code is in a file called .htdb. in idex i refer to it like so: > > <?php > require(".htdb"); > require(".htheader"); > ?> > > I know this type of thing can be done in ASP, has anyone done it in > php? > > Thanks, > ----------------------------------------------------------------------- > | Daryl Chance | We start seeing these new accounts being created, | > | -------------- | but that could be an anomaly of the system. After | > | Valuedata, LLC | a day or two, we realized it was someone hacking | > | Memphis, TN | into the system. - Microsoft on thier hacker | > ----------------------------------------------------------------------- > > >

« previous php.general (#23597) next »