-2
$data = array(
    'date' => $time,
    'boxoffice'=> $boxoffice,
    'upcoming'=> $upcoming,
    'intheaters'=> $intheaters,
    'opening' => $opening,
    'user'  => $users,
    'movie' => $movies,
    'star'  => $actors,
    'diractor' => $directores,
    'writer'  => $writeres,
    'cast'  => $casts,
    'comment'=> $comment,
    'image' => $images,
    'genre' => $genre,
    'country'=> $countrycode
);

try {
    $this->db->insert('muvidb_updatehistory',$data);
}
catch (Exception $e){}

I have those codes above in my project, at first it seems working fine but when i looked into my table, the value inserted three times. I’m new in codeigniter and i am stuck with this problem.

Anyone have an idea why is this happening?

Gianpaolo Di Nino
  • 1,139
  • 5
  • 17
Abhilash Joseph
  • 103
  • 1
  • 1
  • 4

2 Answers2

0

Have you checked to see if you have some sort of rewrite trickery or a dev debug tool that would access that URL 3 times? (Or even a referrer search bot, or the like...)

This is why you should probably verify it's a POST request before inserting data. GET requests that adhere to HTTP specs shouldn't alter data...

landons
  • 9,502
  • 3
  • 33
  • 46
0

You probably have poor double submit checking. More information, see my answer here: duplicate data insert in CodeIgniter

Your best bet in this case is to see if the data already exists, and if it does, to update it instead of insert. I'll add an example later.

Community
  • 1
  • 1
Gustav Bertram
  • 14,591
  • 3
  • 40
  • 65