0

SQL を使用して CI の削除オプションを作成しようとしましたが、それでもエラーになるのはなぜですか?

エラー警告:

A Database Error Occurred

Error Number: 1054

Unknown column 'sip' in 'where clause'

select * from t_label where label = sip

Filename: E:\web\rbt.new\system\database\DB_driver.php

Line Number: 330

コード:

function hapus($id_user){
            if($this->session->userdata('username')==TRUE) {
                $name = $this->db->query("select USER_NAME from t_user where USER_ID = $id_user")->row();
                $id_label = $this->db->query("select * from t_label where label = $name->USER_NAME")->row();
                $this->db->query("delete from t_label, t_publisher where t_label.id_label = t_publisher.id_label and t_label.id_label = $id_label->id_label");
                $this->db->delete('t_user', array('USER_ID' => $id_user));
                redirect("registrasi/reg");
            }
        }

私のコードの何が問題なのですか? ここで本当に助けが必要です

4

1 に答える 1

1

文字列を引用する必要があります。これを試して:

$id_label = $this->db->query("select * from t_label where label = '" . $name->USER_NAME . "'")->row();
于 2012-11-07T09:58:29.227 に答える