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

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
ChrisBull
Forum Commoner
Posts: 42
Joined: Fri Aug 20, 2010 7:43 am

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

Post 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
Last edited by ChrisBull on Sat Aug 28, 2010 12:15 pm, edited 1 time in total.
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: I can't see what is wrong.

Post by MindOverBody »

A i can si those two functions are part of some class.
Try to call isInputValid function with $this -> isInputValid( ... )
ChrisBull
Forum Commoner
Posts: 42
Joined: Fri Aug 20, 2010 7:43 am

Re: I can't see what is wrong.

Post 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.
ChrisBull
Forum Commoner
Posts: 42
Joined: Fri Aug 20, 2010 7:43 am

Re: I can't see what is wrong.

Post by ChrisBull »

Ok, silly mistake. I missed the $this-> infront of the function calls.

Thanks for your reply any way.
Post Reply