0

i'm using postman. when i enter mobile number in post man and check it on sql yog some another number is updated over there. i don't know whats happening. other column data is working properly, only problem with mobile field. please help.. thank in advance.

this is my database table

this is what i got after executing the code

this is my controller file

function updt()
{
    $input = (array)json_decode(file_get_contents('php://input'));   
    $this->form_validation->set_rules('id','id','trim|is_natural_no_zero|required');
    $this->form_validation->set_rules('fname','fname','trim');
    $this->form_validation->set_rules('lname','lname','trim');
    $this->form_validation->set_rules('mobile','mobile','exact_length[10]');
    $this->form_validation->set_rules('email','email','trim|valid_email');
    $this->form_validation->set_rules('user','user','trim');
    $this->form_validation->set_rules('password','password','trim');
    $this->form_validation->set_data($input);


    if($this->form_validation->run() == FALSE)
    {
        $out =['status'=>403, 'msg' =>$this->form_validation->error_array()];
        $this->output->set_output(json_encode($out));
    }
    else 
    {
        $data = array();
        $data['id'] = $input['id']; 
        if(isset($input['fname']))     {$data['fname'] =$input['fname'];}
        if(isset($input['lname']))     {$data['lname'] = $input['lname'];}
        if(isset($input['mobile']))    {$data['mobile'] = $input['mobile'];}
        if(isset($input['email']))     {$data['email'] = $input['email'];}
        if(isset($input['user']))      {$data['user'] = $input['user'];}
        if(isset($input['password']))  {$data['password'] = md5($input['password']);}


        $up = $this->mym->updtdata($data);

        if($up['status'] ==1)
        {
            $out = ['status'=>200, 'msg'=>'records uppdated'];
            $this->output->set_output(json_encode($out));
        }
        else
        {
            $out = ['status'=>200, 'msg'=>'Records ont updated'];
            $this->output->set_output(json_encode($out));
        }

    }
}

This is my model function

function updtdata($update)
  {         
        $this->db->where('id',$update['id']);
        $query  = $this->db->update('userdata',$update);
        if($query)
        {
            return array('status'=>1);
        }
        else
        {
            return array('status'=>0, 'msg'=>'Error occurd');
        }
   }
  • i'm not sure but it looks like you defined your mobile field as int and if you look at https://stackoverflow.com/questions/5634104/what-is-the-size-of-column-of-int11-in-mysql-in-bytes, you'll see the max value is `2147483647` - so the problem is most likely, that your phone number is bigger than that. – Atural Oct 01 '18 at 07:43
  • maybe just try print out your query '$this->db->last_query()' and see thats correct or not,if already correct means your database table problem – Ferry Sanjaya Oct 01 '18 at 07:45
  • @sintakonte so how to fix it?? do you have idea? –  Oct 01 '18 at 07:54
  • @FerrySanjaya i have checked and i'm getting correct result. –  Oct 01 '18 at 07:55
  • i help you because you are a new contributor, but keep in mind - searching for some solutions isn't that hard you know ? as you can see at https://stackoverflow.com/questions/1632312/is-bigint8-the-largest-integer-mysql-can-store - big int can store a max value of `9223372036854775807` - so in your case change your column from int to bigint (since you can't locate this problem - one question arises - who created this database? - maybe you should ask your db designer) – Atural Oct 01 '18 at 07:58
  • thank you very much @sintakonte sir.i'm doing practice and I have created this database and i was not aware about this thing as i'm beginner in php, but from next time onward i will take note of it. thanks once again.. –  Oct 01 '18 at 08:06

0 Answers0