include error

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
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

include error

Post by stevestark5000 »

Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "PHP_ControlPanel" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition

I am trying to include the controlpanel.php file. Can I have an example on how to fix this error. thank you.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: include error

Post by califdon »

stevestark5000 wrote:Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "PHP_ControlPanel" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition

I am trying to include the controlpanel.php file. Can I have an example on how to fix this error. thank you.
You'll have to show us the code. The error isn't about "include", it's telling you that there's a syntax error in your class definition. It isn't complete or it is impossible to parse because it is not being defined in the required sequence.
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: include error

Post by stevestark5000 »

Code: Select all

if (!isset($GLOBALS['core'])){
  header("location:../../");
  exit();
}

if(!isset($_SESSION['PHP_ControlPanel'])) {
  $_SESSION['PHP_ControlPanel'] = new PHP_ControlPanel;
}

if (isset($_GET['cp_image_toggle'])){
  PHP_ControlPanel_Tab::toggleImage($_GET['tab']);
}

if (isset($_GET['cp_desc_toggle'])){
  PHP_ControlPanel_Tab::toggleDesc($_GET['tab']);
}

 $GLOBALS['CNT_controlpanel']['title'] = $_SESSION['translate']->it('Control Panel');

$_SESSION['PHP_ControlPanel']->display();
Last edited by califdon on Sun Feb 13, 2011 9:20 pm, edited 1 time in total.
Reason: Fixed syntax=php tag
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: include error

Post by califdon »

Uhh, what is that??? That doesn't look to me like it has anything to do with the error you quoted.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: include error

Post by s.dot »

http://php.net/manual/en/function.main.php

Perhaps that might explain it?
I've never done an object like that.

can $_SESSION['foo']->method() be called like that?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: include error

Post by McInfo »

califdon wrote:The error isn't about "include", it's telling you that there's a syntax error in your class definition.
It's not so much that there is an error in the class definition as that the class definition cannot be found. Apparently, an object of type PHP_ControlPanel has been created and stored in the session. The object exists but the blueprints are missing, so the object is labeled "incomplete".

There must be more to the script than was shown because, while I was able to recreate the error by instantiating an object in the session then excluding its class definition, I was not able to recreate the error without session_start(), which is also absent and necessary to perpetuate the object.
s.dot wrote:can $_SESSION['foo']->method() be called like that?
According to this test script, yes.

Code: Select all

<?php
session_start();
class A {
    var $n = 0;
    function go () {
        return (++$this->n);
    }
}
if (!(isset($_SESSION['a']) && $_SESSION['a'] instanceof A)) {
   $_SESSION['a'] = new A;
}
echo $_SESSION['a']->go();
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: include error

Post by stevestark5000 »

could it be the last line of code? what more do you want be to include for code?
$_SESSION['PHP_ControlPanel']->display();
Post Reply