is there any reasone why the following doesn"t work?

is there any reasone why the following doesn"t work?

am 26.12.2008 00:57:13 von Fred Silsbee

$connection=oci_connect('landon', 'xxxxxxx',$db)
session_start();
$_SESSION['connection'] = $connection;
...
...
...

$connection = $_SESSION['connection'] ; shows nothing!

My program allows many operations on a table re-entering at the top
and deciding what option to do next.

I don't want to keep logging into Oracle but use the previous connection






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

Re: is there any reasone why the following doesn"t work?

am 26.12.2008 03:18:41 von Fred Silsbee

--- On Thu, 12/25/08, Fred Silsbee wrote:

> From: Fred Silsbee
> Subject: is there any reasone why the following doesn't work?
> To: php-db@lists.php.net
> Date: Thursday, December 25, 2008, 11:57 PM
> $connection=oci_connect('landon',
> 'xxxxxxx',$db)
> session_start();
> $_SESSION['connection'] = $connection;
> .
> .
> .
>
> $connection = $_SESSION['connection'] ; shows
> nothing!
>
> My program allows many operations on a table re-entering at
> the top
> and deciding what option to do next.
>
> I don't want to keep logging into Oracle but use the
> previous connection
_____________________________________
answer? when the php code exits, it must detach the connection and even zero the variable $connection in the _SESSION.

Problem is that my complete program never exits!

What constitutes an "exit"

Running this over and over the $connection is not remembered!

session_start();
$connection = $_SESSION['connection'] ;
$conn = $_SESSION['conn'] ;
print($conn);
$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = LMKIIIGDNSID)
)
)";
if(!$connection)
{
echo "OOOPS! NO connection, better make one .................";
if ($connection=oci_connect('landon', 'xxxxx',$db))
{
echo "Successfully connected to Oracle.\n";
$_SESSION['connection'] = $connection;
}
else
{
$err = OCIError();
echo "Oracle Connect Error " . $err['message'];
}
}
else
{

print ("conn0 = ".$connection." ");
}

print ("conn0 = ".$connection." ");
$conn = 5.6;
$_SESSION['conn']= $conn; //this doesn't perish
?>








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

Re: is there any reasone why the following doesn"t work?

am 26.12.2008 03:45:13 von Fred Silsbee

--- On Fri, 12/26/08, Fred Silsbee wrote:

> From: Fred Silsbee
> Subject: Re: is there any reasone why the following doesn't work?
> To: php-db@lists.php.net
> Date: Friday, December 26, 2008, 2:18 AM
> --- On Thu, 12/25/08, Fred Silsbee
> wrote:
>
> > From: Fred Silsbee
> > Subject: is there any reasone why the following
> doesn't work?
> > To: php-db@lists.php.net
> > Date: Thursday, December 25, 2008, 11:57 PM
> > $connection=oci_connect('landon',
> > 'xxxxxxx',$db)
> > session_start();
> > $_SESSION['connection'] = $connection;
> > .
> > .
> > .
> >
> > $connection = $_SESSION['connection'] ;
> shows
> > nothing!
> >
> > My program allows many operations on a table
> re-entering at
> > the top
> > and deciding what option to do next.
> >
> > I don't want to keep logging into Oracle but use
> the
> > previous connection
> _____________________________________
> answer? when the php code exits, it must detach the
> connection and even zero the variable $connection in the
> _SESSION.
>
> Problem is that my complete program never exits!
>
> What constitutes an "exit"
>
> Running this over and over the $connection is not
> remembered!
>
> > session_start();
> $connection = $_SESSION['connection'] ;
> $conn = $_SESSION['conn'] ;
> print($conn);
> $db = "(DESCRIPTION =
> (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT =
> 1521))
> (CONNECT_DATA =
> (SERVER = DEDICATED)
> (SID = LMKIIIGDNSID)
> )
> )";
> if(!$connection)
> {
> echo "OOOPS! NO connection, better make one
> .................";
> if ($connection=oci_connect('landon',
> 'xxxxx',$db))
> {
> echo "Successfully connected to
> Oracle.\n";
> $_SESSION['connection'] =
> $connection;
> }
> else
> {
> $err = OCIError();
> echo "Oracle Connect Error " .
> $err['message'];
> }
> }
> else
> {
>
> print ("conn0 = ".$connection." ");
> }
>
> print ("conn0 = ".$connection." ");
> $conn = 5.6;
> $_SESSION['conn']= $conn; //this doesn't
> perish
> ?>

answer: http://us.php.net/manual/tr/oci8.connection.php ???





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

Re: is there any reasone why the following doesn"t work?

am 26.12.2008 05:30:16 von Trevor Gryffyn

Connections aren't just a data item that can be remembered and passed from
one script execution to another. When you load a PHP powered page through
your web server, it starts running the script and occupies a certain
section of memory. This memory space also holds pointers to things like
database connections. When you dump the values of a connection variable,
you may get a connection ID number, but don't mistake that for something
you can pass from one script to another.

When the PHP script gets to the end, it exits. Freeing up the memory and
resources it was using. Your connection is closed, even if you didn't
specifically close it.

You can look into setting up a "persistant" connection. I believe that's
what you're aiming for. Honestly, I've never looked into the benefits and
drawbacks of using persistant connections. I like to keep things clean,
and the things I've worked on haven't been so intensive that they suffered
from opening a connection per page load.

It's good to keep the "connect" commands to a minimum, as they're very system
intensive (comparatively) but most times, having one "connect" at the head
of your script and closing it at the end of the script execution isn't a
big deal. But you won't be able to pass the connection information via
session variables.

-TG

----- Original Message -----
From: Fred Silsbee
To: php-db@lists.php.net
Date: Thu, 25 Dec 2008 15:57:13 -0800 (PST)
Subject: [PHP-DB] is there any reasone why the following doesn't work?

> $connection=oci_connect('landon', 'xxxxxxx',$db)
> session_start();
> $_SESSION['connection'] = $connection;
> ..
> ..
> ..
>
> $connection = $_SESSION['connection'] ; shows nothing!
>
> My program allows many operations on a table re-entering at the top
> and deciding what option to do next.
>
> I don't want to keep logging into Oracle but use the previous connection


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