#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    6
    Rep Power
    0
    Hi,

    Maybe you guys can help you!?

    I have a small website, and I initialize a class on the front page and stored it in a session, and everything works fine, including the class's functions. After passing the class in a session, and recall it on a different page. Thats when I run into problems. When i try to echo the variables, that works. BUT when I try to access a function, it tells me "Call to undefined function"

    Help!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16
    1) Are you using PHP4?


    2) Could you provide the code?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    6
    Rep Power
    0
    1) yes i am using PHP4

    2) The SIMPLE version of the code is as follows:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    //class.inc
    class user{
    var $user_connection;
    var $username;
    var $fullname;
    var $perms;

    function user(){
    /* establishes all connections and initializes the class */
    }

    function verify_user(){
    //just stuff that verifies the user
    }
    function log_user($action = 'null'){
    //log a user
    }
    } [/quote]

    Then on my index.php page:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    session_start();

    if (!isset($session)){
    $session = new user();
    $session->verify_user();
    session_register("session");
    }


    $session->log_user("Action is bla");

    [/quote]
    That works. As you can see I store the session, and i recall it on another page and the session is there. Here is the code for the page:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>


    session_start();
    if (!isset($session))
    {
    echo "Error: You are not logged in!";
    exit();
    }
    else
    require('class_admin.inc'); //thats the name of the script, still get hte same message with or without it.

    <?

    echo session->fullname; //this line works
    $session->log_user("Action is bnl"); //this line doesnt


    [/quote]


    Please get back to me, this is important thank you!

Similar Threads

  1. functions slowing code
    By dave2k in forum PHP Development
    Replies: 5
    Last Post: February 7th, 2004, 06:40 PM
  2. problem with functions
    By veni123 in forum C Programming
    Replies: 8
    Last Post: February 5th, 2004, 02:22 PM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 2
    Last Post: January 9th, 2004, 02:26 PM
  4. Replies: 10
    Last Post: November 1st, 2003, 05:50 AM
  5. classes and function declaration
    By irishsk in forum PHP Development
    Replies: 4
    Last Post: August 18th, 2003, 11:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo