• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help! delete record doesn’t work

[eluser]red apple[/eluser]
Hi everyone,

I'm new in this forum and also I'm learning to use the CI. I was able to finish an project using CI and everything works great with an little exception. Even if I try to find my error, I could not solve my probleme.

Here below you can see my model delete function:

function delete_cd($cd_id, $cd_name, $cd_type, $cd_description)
$data = array('cd_id'=> $cd_id, 'cd_name' => $cd_name, 'cd_type' => $cd_type, 'cd_description' => $cd_description);
$this->db->where('cd_id', $cd_id);

And here is my controler's function:

function delete_cd()
$cd_id = $_POST['txtcd_id'];
$this->db->set('cd_id', $cd_id);
$cd_name = $_POST['txtcd_name'];
$this->db->set('cd_name', $cd_name);
$cd_type = $_POST['txtcd_type'];
$this->db->set('cd_type', $cd_type);
$cd_description = $_POST['txtcd_description'];
$this->db->set('cd_description', $cd_description);

$data['query'] = $this->Videotek->delete_cd($cd_id, $cd_name, $cd_type, $cd_description);

$data['query'] = $this->Videotek->get_info($username);
$this->load->view('vaudio', $data);

Thanks in advance
I realy need to solv that probleme, .... my due date for this project is tomorrow ...
Sorry for my englesh

try this function in Model
//ignore other three paramets
function delete_cd($cd_id, $cd_name, $cd_type, $cd_description){
$sql = "DELETE from audio where cd_id= ?";


function delete_cd(){
$this->load->view(’vaudio’, $data);
$data['query'] = $cd_id = $_POST[’txtcd_id’];
$data['query'] = $this->Videotek->delete_cd($cd_id);

I dint get why you are using $this->db->set();
Are u updting ?


function delete_cd(){
$cd_id = $_POST[’txtcd_id’];
$data[’query’] = $this->Videotek->delete_cd($cd_id);
$this->load->view(’vaudio’, $data);

[eluser]red apple[/eluser]
Thanks for your answer, unfortunatelly works not and I have an error message:

Error number: 1054
Unknown column '10126' in 'where clause'
DELETE from audio where cd_id = 10126

the 10126 is the cd id, I want to delete from my videotek.

just replace from audio to videotek

DELETE from videotek where cd_id = ?";

[eluser]red apple[/eluser]

Thanks again for your answer, but there is the never ending story ... It's stupid, I was able to solv difficult problems and now I'm stocked here ...

I could not replace the audio with videotek, because the videotek is my database who contain a lot of table like audio, video ... I want to delete an cd from my data base, which is found in audio table.
I have the modiffy function and I use the cd id also and all work great, but for delete ...doesn't matter how I wrote the function I have the same error message.

escuse my englesh

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.