Page 1 of 1
include error
Posted: Sun Feb 13, 2011 7:46 pm
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.
Re: include error
Posted: Sun Feb 13, 2011 8:26 pm
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.
Re: include error
Posted: Sun Feb 13, 2011 8:50 pm
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();
Re: include error
Posted: Sun Feb 13, 2011 9:24 pm
by califdon
Uhh, what is that??? That doesn't look to me like it has anything to do with the error you quoted.
Re: include error
Posted: Sun Feb 13, 2011 9:54 pm
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?
Re: include error
Posted: Sun Feb 13, 2011 11:22 pm
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();
Re: include error
Posted: Sun Feb 13, 2011 11:48 pm
by stevestark5000
could it be the last line of code? what more do you want be to include for code?
$_SESSION['PHP_ControlPanel']->display();