Jump to content

Fatal error: Cannot use object of type reg_validate as array


hmvrulz

Recommended Posts

my Class

class reg_validate extends validate
{
public $errors = array();

function __construct($input)
{
	$this->errors['username'] = $this->username($input['username']);
	$this->errors['password'] = $this->password($input['password1'], $input['password2']);
	$this->errors['email'] = $this->email($input['email']);

	print_r($this->errors);

	return $this->errors;

}

function reg_error($input)
{
	print_r($input);
	switch ($input['username']) {
		case '-1':
			echo 'error -1';
			break;
		case '-2':
			echo 'error -2';
			break;
		case '-3':
			echo 'error -3';
			break;
	}
}

}

 

INITIALIZING

$reg_validate = new reg_validate($_POST);

$reg_validate->reg_error($reg_validate);

 

Object

reg_validate Object
(
    [errors] => Array
        (
            [username] => -3
            [password] => -2
            [email] => 1
        )

    [minUser] => 3
    [minPass] => 6
)

ERROR am GETTING

Fatal error: Cannot use object of type reg_validate as array in C:\Program Files\wamp\www\fw\models\users.php on line 31

 

 

 

 

 

HOW can i use the $input[username] in the switch to check for errors

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.