Welcome Guest, Not a member yet? Register   Sign In
Updating a MySql table issue
#1

(This post was last modified: 07-18-2016, 08:40 AM by frobak.)

I am having an issue with updating a MySql table using codeigniter.

Basically, its inserting 'img' the characters, into the table column 'progress' rather than the value of the variable ($progress).

This is so strange!

Here is my model:


PHP Code:
    public function update_course_progress($progress_data) {
        $course_id  $progress_data['course_id'];
        $user_id   $progress_data['user_id'];
        $progress $progress_data['progress'];
        $status $progress_data['status'];
    
        $update_data 
= array (
            'progress'  => $progress,
            'status'    => $status,
        );
        // perform update on the matching row
        $this->db->update('training_stats'$update_data, array('course_id' => $course_id'user_id' => $user_id));
    


So, the issue is with 'progress' instead of inserting the value of this variable it is inserting 'img'???

So, if i var_dump $update_data i get this:

   
PHP Code:
array(2) { ["progress"]=> string(2"1a" ["status"]=> string(1"i" 


Which is correct:

And if i use the profiler in CI to get the db queries, this is what I get:


PHP Code:
     UPDATE `training_statsSET `progress` = '1a', `status` = 'i'
    WHERE `course_id` = '8'
    AND `user_id` = '2'   


Which is correct.

So why is it inserting 'img' into the db instead of 1a.

The table structure for this column is VARCHAR(4).


Code:
    progress varchar(4) NOT NULL DEFAULT '0',

I'm not getting any errors, and if I input the query above directly into phpmyadmin it works fine?

What can be wrong?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB