"Minghua Yao" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> > Hi,
> > On one page, I have:
> > <?php
> > .......
> > $dbcnx0 = @mysql_connect("localhost", $name, $password);
> > .......
> > session_start();
> > $_SESSION['my_con'] = $dbcnx0;
> > .......
> > ?>
> > On another page, I have:
> > <?php
> > ..........
> > session_start();
> > $dbcnx1 = $_SESSION['my_con'];
> > .........
> > ?>
> > The problem is:
> > $dbcnx0 = Resource id #1 while $dbcnx1 = 0.
> > The reason I want to pass the handle to next page is that I want to use
> > that connection on the next page to do some queries.
> > Help will be appreciated.
> > -MY

You cannot do what you propose and there is no work around becuase PHP
automatically closes any connctions left open when the script closes,
rendering the resource/object handels invalid.

The compromise most people live with is to put their connection script
within a separate file and include it (either manually or automatically) at
the top of any script they may need to access the database in.  This at
least saves you the headache of maintaining twelve different instances of
the same code in a pile of scripts.

- Kevin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to