php - Issue with if /elseif /else -


i creating whitelist if user input data. getting stuck on elseif statements.

this code :

public function is_valid_data($data)    {       if(strlen($data > 9))      {        $this -> set_message('is_valid_data', 'field needs less 9 characters');        return false;      }      elseif(strlen($data < 9))      {        $this -> set_message('is_valid_data', 'field can not under 9 characters');        return false;      }      elseif((substr($str, 0, 1) !== 'testing') || (substr($str, 0, 1) !== 'test'))      {        $this -> set_message('is_valid_data', 'please re-submit data!');        return false;      }      elseif(!preg_match("/^[0-9]/", $str))      {        $this -> set_message('is_valid_data', 'please dont forget numbers!');        return false;      }      else      {        return true;      }     } 

for reason if $data 9 characters first if statements goes through, second 1 fails , keep getting 'field can not under 9 characters' though $data 9 characters. returning false because in script have function call is_valid_data($data) , if function returns false return error user. if returns true data valid , can continue

i can't seem shake issue.

if(strlen($data) > 9) 

instead of

if(strlen($data > 9)) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -