Page 1 of 1

[Solved]I can't see what is wrong.

Posted: Sat Aug 28, 2010 7:25 am
by ChrisBull
Hi, i have this code which to me shoulld be perfect but i can't get it to work.

Code: Select all

private function isDataValid() 
	{	
	$tempVar = true;
   	$tempVar = isInputValid($this->_userMail); ///////// <- This is line 60
    	$tempVar = isInputValid($this->_userPassword);
    	return $tempVar;
	}
	
private function isInputValid($tempVar)
	{
	if (empty($tempVar)) { return false; }      	
    	if (preg_match('[^a-zA-Z0-9+=@."]', $tempVar)) { return false; }
    	return true;
	}
This is the error that the browser gives.
Fatal error: Call to undefined function isInputValid() in / "site directory" /scripts/php/class/UserAccount.php on line 60
Many Thanks
Chris

Re: I can't see what is wrong.

Posted: Sat Aug 28, 2010 10:20 am
by MindOverBody
A i can si those two functions are part of some class.
Try to call isInputValid function with $this -> isInputValid( ... )

Re: I can't see what is wrong.

Posted: Sat Aug 28, 2010 11:51 am
by ChrisBull
Hi, I made the function isInputValid() a public function and called it from outside the class with a test string "hello" and it returned '1' which i assume means true. So it does work, but why not from inside the other function. I also tried calling the function using $this->isInputValid("hello") from inside the classes constructor and it still came up with the error on line 60 rather than the constructor so it worked from inside the constructor.

Re: I can't see what is wrong.

Posted: Sat Aug 28, 2010 11:54 am
by ChrisBull
Ok, silly mistake. I missed the $this-> infront of the function calls.

Thanks for your reply any way.