Fatal error: Call to a member function
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Fatal error: Call to a member function

  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Fatal error: Call to a member function

    i'm trying to unserialize Object. i run the documentaion sample.
    code for classa.inc:

    PHP Code:
    <?php
    class {
         var 
    $one 1;
         function 
    show_one() {
             echo 
    $this->one;
         }

      }
    ?>

    code for page1:
    PHP Code:
    <?php
    session_start
    ();
    include(
    "classa.inc");
    $a = new A;
    $s serialize($a);
    setcookie("test",$s);
    $nextPage "page2.php";
    header("Location: $nextPage");
    ?>
    code for page2:
    PHP Code:
    <?php
    include("classa.inc");
    $s =$_COOKIE["test"];
    $a unserialize($s);
    if(
    is_object($a)){
        echo 
    "a is an Object!<br/>"  ;
        
    $a->show_one();
    }else{
        echo 
    "a is not an Object!<br/>";
    }
    ?>
    Simple right.
    result when run page1
    a is not an Object!
    i check and cookie test have been creted
    i can't find why i cant use the object?
    thanks for any help..
    Last edited by PeejAvery; January 14th, 2010 at 01:34 PM. Reason: Added PHP tags.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,875

    Re: Fatal error: Call to a member function

    Don't you love magic quotes?

    PHP Code:
    $s stripslashes($_COOKIE["test"]); 
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center