1

Can somebody tell me why my update did not work ?

Here are the data in my variable $id = '1'; $table = 'tb_home_content'; $data = Array ( [title] => SLEEK DESIGN [content] => We have a sleek design which not only attractive but simple in design for our user to see. [classicon] => fa fa-clone );

Here are my model function

    public function updateData($table, $data)
    {
        $id = $data['id'];
        array_shift($data);

        // echo $id.'<br>';
        // echo $table.'<br>';
        // print_r($data);

        $this->db->where('id', $id);
        $this->db->update($table, $data);

        if($this->db->affected_rows() == '1')
        {
            echo "<script>";
                echo "alert('Success');";
            echo "</script>";
        }
        else
        {
            echo "<script>";
                echo "alert('Failed');";
            echo "</script>";
        }

1 Answer 1

1

What is the error message you are getting? Are you sure the value at the position of id is the first element in the array?

Sign up to request clarification or add additional context in comments.

5 Comments

jquery.min.js:2 POST admin/actioninsert 500 (Internal Server Error)
I could echo the variable which show this $id = '1'; $table = 'tb_home_content'; $data = Array ( [title] => SLEEK DESIGN [content] => We have a sleek design which not only attractive but simple in design for our user to see. [classicon] => fa fa-clone ); but the update did not work
@user2977799 Try to echo or var_dump the error message using $this->db->error()
I could only get this result array(2) { ["code"]=> int(0) ["message"]=> string(0) "" } if i put var_dump($this->db->error()); below the code else code and give comment in where and update line.
Sorry, you're right, seems like my data are wrong. is should be class_icon in the array not classicon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.