SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can this be a non-object?

    I really like PHP, but I miss the debugging abilities of PERL.


    Code:
    include_once ("kwoon.php");
    $newKwoon = new kwoon();
    $retval = $newKwoon->kwoonVerify($kwoonname, $password, $activation);
    // test for retval
    if (strlen($retval) > 1) {
    	$myoutput = new output();
    	// display error page
    	$myoutput->dispError($retval);			
    	exit;
    }
    $newKwoon->kwoonByName($kwoonname);
    
    //The infamous line 119 below
    $newKwoon->kwoonActivate($kwoonname);
    Running this results in the last line ($newKwoon->kwoonActivate) giving this error

    Fatal error: Call to a member function on a non-object in /home/virtual/dragonslist/home/httpd/html/fun/game/signup.php on line 119
    How can $newKwoon, that has been initialized and used twice already before this line, suddently become a non-object?

    Maybe I just don't understand the error message

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    lalal
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you have a function kwoonActivate declared in your class ???? my guess is you don't

  3. #3
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply.

    I must admit this problem doesn't make sense to me at all.

    I do have the function kwoonActivate, and I was conviced the error was in there, so I reduced it to this (and still have the problem):

    Code:
    		// set activation flag and kwoon defaults
    		function kwoonActivate() {
                                   echo "test";
    		}

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ONe thing that strikes me as odd, and might be causing the problem is the line above line 119. In your original post on this subject
    http://www.sitepointforums.com/showt...threadid=26227

    Your method
    PHP Code:
    // get kwoon info by kwoon name 
    function kwoonByName() { 

    // database connection info 
    require ("dlgame.php"); 

    // check for persistant database connection 
    mysql_pconnect("localhost"$dbuser$dbpass); 

    $query "SELECT * from players where kwoon='$inputKwoonName'"
    $result mysql_db_query($dbname$query); 
    $kwoon mysql_fetch_assoc ($result); 
    mysql_free_result($result); 
    $this $kwoon


    function kwoonByName()

    takes no parameters but you call it with one.

    $newKwoon->kwoonByName($kwoonname);


    This mya be part of the problem, unless of course you already fixed that part.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I modified it to no longer user parameters in one of my many attempts to fix this.

    You have a good memory!

  6. #6
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the problem, but I don't understand it.

    It appears the problem was in the function kwoonByName. This function takes a name and attempts to fill the object with the correct values (like the constructor, except the constructor takes the id and in this case the id isn't known, but the name is).

    Here is the code, once I removed it (actually I combined it with another function) it works just fine:

    Code:
    		// return kwoon id by kwoon name
    		function kwoonByName($inputKwoonName) {
    			// database connection info
    			require ("dlgame.php");
    
    			// check for persistant database connection
    			mysql_pconnect("localhost", $dbuser, $dbpass);
    	
    			$query = "SELECT * from players where kwoon='$inputKwoonName'";
    			$result = mysql_db_query($dbname, $query); 
    			$outKwoon = mysql_fetch_assoc ($result);
    			$this = $outKwoon;
    			mysql_free_result($result);
    		}


Bookmarks

Posting Permissions

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