Forums

error save twice items in database???

mrkalen 13 Dec, 2012
Hi,
I have a problem, when i submit form and show success message, i coded save item in custom PHPcode at Before. But it saved twice item in database:

//======== save database ==========
if(!class_exists('Tablebook_downloads')){
  class Tablebook_downloads extends JTable{
    var $email = null;
    var $items_id = null;
    var $date_reg = null;
    var $status = null;
    var $active_code = null;

    function __construct(&$database){
      parent::__construct('nn9po_book_downloads', 'id', $database);
    }
  }
  $record =& JTable::getInstance('book_downloads', "Table");
  if(!$record->save($data)){
    JError::raiseWarning(100, $record->getError());
  }
}

Image here:

How to fix it? thanks!!!
GreyHead 13 Dec, 2012
Hi mrkalen,

Use the built-in DB Save action; or, if you choose to write you own code then you get the delights of debugging it too :-(

Bob
mrkalen 13 Dec, 2012
thanks, so i try use DB Save😟 thanks GreyHead🙂
This topic is locked and no more replies can be posted.