Page 1 of 1

Is there a broblem...

Posted: Tue Sep 24, 2002 4:35 am
by royalhunt
...when you unserialize an object that has as an attribute a connection to an Oracle server?
I serialize an object that has a connection as an attribute echo the type of this attribute object and get as a result something like "Resource id #2"
and after i unserialize the object again the same thing gives 0!!!
:( I HATE MY JOB!!!!!!!! Please help me with that.

Posted: Tue Sep 24, 2002 4:53 am
by Coco
http://www.skywalker.gr
:lol: :lol:

im too much of a newbie to help you with seralize further than pointing you to user comments in the manual

!!!!!!!

Posted: Tue Sep 24, 2002 4:56 am
by royalhunt
Sorry?!?!?!? What does skywalker has to do with that?!?!?!? (perhaps the coffee never operated successfully this morning!!!) Greek?!?!?

Posted: Tue Sep 24, 2002 4:58 am
by Coco
royalhunt
Forum Newbie


Joined: 20 Sep 2002
Posts: 7
Location: Greece


skywalker is a greek job site

Ok..

Posted: Tue Sep 24, 2002 4:59 am
by royalhunt
..the coffee i had really didn't do anything this morning!!!!!!!! 8O

Re: Is there a broblem...

Posted: Tue Sep 24, 2002 5:02 am
by Coco
royalhunt wrote: :( I HATE MY JOB!!!!!!!! Please help me with that.

PLEASE SOMEONE HELP

Posted: Tue Sep 24, 2002 6:12 am
by royalhunt
PLEASE GUYS. IT'S A MAJOR PROBLEM FOR ME (started working with PHP only 5 days).
What the hell is wrong with this!!!

Posted: Tue Sep 24, 2002 6:19 am
by twigletmac
What exactly (ie. can we see some code) are you trying to serialise/unserialise.

Mac

Code

Posted: Tue Sep 24, 2002 6:29 am
by royalhunt
Ok there is a class OracleCon which has the following:

Code: Select all

class OracleCon{
   var $username;
   var $password;
   var $alias;
   var $conn;
as attrributes and a function

Code: Select all

function ConnectToDB(){
   $this->conn = @OCINLogon($this->username, $this->password, $this->alias);
  if (!OCIError()){
    return true;
  }else{
    return false;
  }
}
that is used to connect to an oracle database

in a file called login.php i have the following:

Code: Select all

$oracle = new OracleCon($username, $password, "DEV_ORION");
    if ($oracle->ConnectToDB()) {
      $connection = serialize($oracle);
      $connection = urlencode($connection);
      if (setcookie("login", $connection)){
        header("Location: search.php");
      }else{
        exit;
     }
and in the file search.php i have the following:

Code: Select all

include "OracleCon.inc";
$connection = $HTTP_COOKIE_VARSї'login'];
$connection = urldecode($connection);
$oracle = unserialize($connection);
$oracle->CreateStatement();
$oracle->ExecuteStatement();
$oracle->ShowResults();

i login successfully and try to access the conn attribute since i need to run a statement in search.php. I get the following message:

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in c:\program files\apache group\apache\htdocs\php\OracleCon.inc on line 66

I echoed the $oracle->conn in the login2.php and i get "Resource id #2". I echoed the $oracle->conn in the search.php and i get "0"!!!! The other attributes are set correctly (in the search.php file they still have their values)

Posted: Tue Sep 24, 2002 5:08 pm
by volka
.You cannot serialize resources. All that will remain is the string representation ("Resource id #2").
But you may use The magic functions __sleep and __wakeup to try to re-establish the connection.