执行数据库查询时出现以下错误:
发生数据库错误
错误号码:1062
键'PRIMARY'重复输入'1'
更新
tbl_galeri
设置id_galeri
='1',galeri_kat_id
='1',nama
='Elyza Okiliyandass',foto
= 0,{ {1}} ='Elyza Okiliyanda'文件名:C:\ xampp \ htdocs \ indonesiausher \ system \ database \ DB_driver.php
行号:330
控制器:
deskripsi
型号:
$pilih['id_galeri'] = $this->uri->segment(3);
$dt_galeri = $this->app_model->getSelectedData("tbl_galeri",$pilih);
foreach($dt_galeri->result() as $db)
{
$bc['id_galeri'] = $db->id_galeri;
$bc['galeri_kat_id'] = $db->galeri_kat_id;
$bc['nama'] = $db->nama;
$bc['foto'] = $db->foto;
$bc['deskripsi'] = $db->deskripsi;
$bc['stts'] = "edit";
}
$this->load->view('backend/gallery/bg_input_usher',$bc);
}
如何处理此错误? 感谢..
答案 0 :(得分:0)
尝试删除id_galeri
查询
UPDATE
,如下所示
UPDATE tbl_galeri SET galeri_kat_id = '1', nama = 'Elyza Okiliyandass', foto = 0, deskripsi = 'Elyza Okiliyanda' WHERE id_galeri = '1'
修改强>
您可能不需要更新PRIMARY
& AUTO INCREMENT
密钥。请删除id_galeri
答案 1 :(得分:0)
我认为您的SQL语句不完整。您应该具有以下内容:
UPDATE表SET字段='$ value'WHERE id ='$ id'
答案 2 :(得分:0)
您可以签出主键字段自动递增字段。
如果在表中存储了任何数据,则首先全部备份数据,然后删除数据,然后更改表table
更改your primary key field
your primary key field
INT(11)NOT NULL AUTO_INCREMENT;