提供的参数无效Codeigniter

My program is not working properly, i do not know what should i do :S

I got this error message: enter image description here

Take a look at this: enter image description here

Here is my code: My controller file (Home):

    <?php

    class Home extends CI_Controller{

         public function __construct(){
             parent::__construct();

             $this->load->model("Crudmodel");

        }


 public function index(){

    # get all data in Study table
    $selectStudys = $this->Crudmodel->selectStudys();


    foreach ($selectStudys as $key => $study) 
    {
        # get UserNames
        $user = $this->Crudmodel->getName($study['user_id']);

        #get Subject Names
        $subject = $this->Crudmodel->getSubName($study['subject_id']);


        #append both NEW VALUES to same array

        if(!empty($user[0]['username'])){
        $data[$key]['user_id'] = $user[0]['username'];
        // your main problem can be this. may be it is not getting value from query this is why we have put validation on model function and error handler condition here
        }else{
         $data[$key]['user_id'] = ''; // or anything as your else condition you can use as error handler 
        }
        if(!empty($subject[0]['name'])){
        $data[$key]['subject_id'] = $subject[0]['name'];
        // your main problem can be this. may be it is not getting value from query this is why we have put validation on model function and error handler condition here
        }else{
           $data[$key]["subject_id"] = "";
          // or anything you can use as error handler
        }

    }


    $data['records'] = $selectStudys;
    $this->load->view('home', $data);

}

}
?>

Crudmodel:

       class Crudmodel extends CI_Model{

        public function __construct(){
         parent::__construct();

         $this->load->database();

        }


        function selectStudys()
{
    $query= $this->db->query("SELECT * FROM cursadas");
    if($query->num_rows()>0){
       $result = $query->result_array();
     }else{
      $result = "";
          // or anything you can use as error handler
      return $result;
    }
}

function getName($name)
{
    $query= $this->db->query("SELECT username FROM usuarios WHERE id = $name ");
    if($query->num_rows()>0){
    $result = $query->result_array();
    }else{
    $result = "";
          // or anything you can use as error handler
    return $result;
  }
}

Dont know what to do now :(

Hope you can help me :S

The problem is in the model. You only return something inside the else. Easy fix, move the return.

You should probably return an empty array if there are no rows. Then the foreach will still have something to work with - even if it is empty. foreach will choke if given something that cannot be used in a loop - a string for instance.

function selectStudys()
{
    $query= $this->db->query("SELECT * FROM cursadas");
    if($query->num_rows()>0){
       $result = $query->result_array();
     }else{
      $result = array();
    }
    return $result;
}