Problem with an array

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have the following line:

if($newValidate->isNotEmpty($this->userName) &&  

which checks to see if two text boxes contain any data. However if both  
boxes are empty, it only displays the error message once. Below is the  
Validate class.


class Validate
private $valueToCheck;
private $errorMessage;

function printErrorMessage ()
print $this->errorMessage[0];
print $this->errorMessage[1];

function isNotEmpty($valueToCheck)
if (!empty($valueToCheck))
return TRUE;
$message = "A field is empty.";
$this->errorMessage[] = $message;
return FALSE;

Re: Problem with an array

Phil Latio wrote:
Quoted text here. Click to load it

If the first statement evaluates to false, the other statement won't be
Try something along the lines of:
if($newValidate->isEmpty($this->userName) ||

Rik Wasmus

Re: Problem with an array

Quoted text here. Click to load it

I replaced && with || and it worked !!!

Many thanks for the quick reply. I would have taken some time to work out it  
was the use of && in the statement that was causing the problem.



Site Timeline