Hello all. I used to have hair, but now I don't. We can thank OOP for this. :)
I have an employee class and a second script where all of my calls are for the employee class.
I need to build some validation into this application. My problems are with dropdown boxes.
In my second script, I instantiate the object and all is well and good. I get a return value from the method and if true, write to the db, if false, I need to display an error. This is where all of my issues are at.
I thought about using a SESSION but couldn't get that to work. I tried a POST var and couldn't get that to work either. By the way, this form is posting back to itself. Not sure why POST wouldn't work.
Then it dawned on me that the simplest way I can think of to accomplish this task is by creating another method called ShowError()
[PHP]
public function ShowError($erro r)
{
$this->error = $error
return $this->error;
}
[/PHP]
In the constructor, I have initialized the var $error as a member and set the variable as public.
Outside of the ShowError() method, I am attempting to call the member but it will not echo. What gives? I know I am doing something wrong but I haven't got a clue.
Should I be using global for this? I thought with OOP I could call that member ANYWHERE in the class.
Could someone please help?
Thanks,
Frank
I have an employee class and a second script where all of my calls are for the employee class.
I need to build some validation into this application. My problems are with dropdown boxes.
In my second script, I instantiate the object and all is well and good. I get a return value from the method and if true, write to the db, if false, I need to display an error. This is where all of my issues are at.
I thought about using a SESSION but couldn't get that to work. I tried a POST var and couldn't get that to work either. By the way, this form is posting back to itself. Not sure why POST wouldn't work.
Then it dawned on me that the simplest way I can think of to accomplish this task is by creating another method called ShowError()
[PHP]
public function ShowError($erro r)
{
$this->error = $error
return $this->error;
}
[/PHP]
In the constructor, I have initialized the var $error as a member and set the variable as public.
Outside of the ShowError() method, I am attempting to call the member but it will not echo. What gives? I know I am doing something wrong but I haven't got a clue.
Should I be using global for this? I thought with OOP I could call that member ANYWHERE in the class.
Could someone please help?
Thanks,
Frank
Comment