Is there a broblem...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
royalhunt
Forum Newbie
Posts: 10
Joined: Fri Sep 20, 2002 4:25 am
Location: Greece
Contact:

Is there a broblem...

Post 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.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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
royalhunt
Forum Newbie
Posts: 10
Joined: Fri Sep 20, 2002 4:25 am
Location: Greece
Contact:

!!!!!!!

Post by royalhunt »

Sorry?!?!?!? What does skywalker has to do with that?!?!?!? (perhaps the coffee never operated successfully this morning!!!) Greek?!?!?
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

royalhunt
Forum Newbie


Joined: 20 Sep 2002
Posts: 7
Location: Greece


skywalker is a greek job site
royalhunt
Forum Newbie
Posts: 10
Joined: Fri Sep 20, 2002 4:25 am
Location: Greece
Contact:

Ok..

Post by royalhunt »

..the coffee i had really didn't do anything this morning!!!!!!!! 8O
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Re: Is there a broblem...

Post by Coco »

royalhunt wrote: :( I HATE MY JOB!!!!!!!! Please help me with that.
royalhunt
Forum Newbie
Posts: 10
Joined: Fri Sep 20, 2002 4:25 am
Location: Greece
Contact:

PLEASE SOMEONE HELP

Post 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!!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly (ie. can we see some code) are you trying to serialise/unserialise.

Mac
royalhunt
Forum Newbie
Posts: 10
Joined: Fri Sep 20, 2002 4:25 am
Location: Greece
Contact:

Code

Post 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)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply