Fatal error: Really stuck, Help Please
I have suddenly recieved this error in my code, I have changed nothing and yet suddenly it throws up an error
The error is -
Fatal error: Call to a member function addDetention() on a non-object in G:\Inetpub\WWWroot\services\detention\inc\class\domain\dt.php on line 65
The code is -
public function setStaff($staffObj) {
$this->staff = $staffObj;
$staffObj->addDetention($this);
}
Any help would be much apprieciated
[482 byte] By [
smudge] at [2007-11-20 10:42:58]

# 1 Re: Fatal error: Really stuck, Help Please
The error says $staffObj is not an object instance. Try var_dump()'ing $staffObj and see what its value is when passed to the function. It's probably null or some type value such as integer, string, etc.
# 2 Re: Fatal error: Really stuck, Help Please
Sorry, can you explain to me how to do that?
Thanks
smudge at 2007-11-10 3:57:11 >

# 3 Re: Fatal error: Really stuck, Help Please
In short...your function is trying to assign an object value to $staffObj. The variable $staffObj has not been declared as an object yet. Somewhere you need to go back in your code and find where it is declared and make sure that it is an object.
# 4 Re: Fatal error: Really stuck, Help Please
By "var_dump()'ing $staffObj" I simply mean running var_dump($staffObj);. Read the PHP manual on var_dump: http://www.php.net/var_dump
You can also read up on print_r: http://www.php.net/print_r
# 5 Re: Fatal error: Really stuck, Help Please
In short...your function is trying to assign an object value to $staffObj. The variable $staffObj has not been declared as an object yet. Somewhere you need to go back in your code and find where it is declared and make sure that it is an object.
Isn't that the line of code above the error?
smudge at 2007-11-10 4:00:10 >

# 6 Re: Fatal error: Really stuck, Help Please
Just check what $staffObj is. It is not an object instance, and that is why you're getting the fatal error when trying to call a method on it.
# 7 Re: Fatal error: Really stuck, Help Please
Ok i have run var_dump($staffObj) and it returned bool(false). Do this help in anyway?
smudge at 2007-11-10 4:02:13 >

# 8 Re: Fatal error: Really stuck, Help Please
It means you're trying to run the equivalent of the following code:
false->addDetention($this);
I can't help you more now, you have to figure out yourself why $staffObj is equal to false and not an object instance.
# 9 Re: Fatal error: Really stuck, Help Please
Thats what i can't figure out because the code has been working fine for well over a year now and suddenly it stops.
smudge at 2007-11-10 4:04:23 >
