kurrata
kurrata

Reputation: 1

variable changes for unknown reason(maybe)

i have this function

    function ecr_form_save($data) {
/* data value
array(
['result'] =>
'ok'
)
*/
        $result = validate_form($data);
        global $firephp;    
        $firephp->log($result, 'Iterators');
        //return $result;   //return 1

        if ($result['result']=="ok") {
            return $result; //return 2
        } else {
            return $result; //return 3
        }

    }

When i uncoment return 1 everything works, but if i comment return 1 and try to get output from return 2 or 3 i get error

Any idea what is going on with that.

yes ,it is always is returning array like this array('result'=>'ok') or like this array('error'=>'"Beigu rādījums" ir jābūt veselam skaitlim') , depending on what input form has.

if i change if statement to if ( 1==1) it works to

Upvotes: 0

Views: 60

Answers (3)

zaf
zaf

Reputation: 23244

Try changing your if statement to:

if( is_array($result) && isset($result['result']) && $result['result']=="ok" ){

Upvotes: 1

Benjie
Benjie

Reputation: 7946

I suggest you var_dump($result) after 'return 1' - it might not be a true array.

Upvotes: 1

user962293
user962293

Reputation:

u have to do

array("result" =>"ok");

now try it's work.

Upvotes: 0

Related Questions