Level 50
Post the full error message. It shows you where the error is.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm having problems with the code I created, but I've tried it and there's no result.
file controller : portal.php
function pembayaran(){
$kode = $this->auth['kode'];
$stsConfirm = $this->db2->query("SELECT stsApplyPaid, stsApplyPaidConfirm, applyBankTransferAmount, kode_voucher FROM adis_smb_form WHERE kode = '$kode'")->row();
$voucher = $stsConfirm->kode_voucher;
$transfer_amount = $stsConfirm->applyBankTransferAmount;
$cmb = $this->mportal->mCmb($kode);
$year = date('Y');
$minYearLulus = $year - 4;
$dataVoucher = null;
if ($voucher) {
$dataVoucher = $this->mportal->getDataVoucher($voucher);
}
$harga = $this->mportal->getTotalBayar($dataVoucher->kode_voucher); // error from here
$this->smarty->assign([
'biaya' => $harga,
'kode_voucher' => $voucher,
'data_voucher' => $dataVoucher,
'transfer_amount' => $transfer_amount,
'breadcum' => $breadcum,
'site' => $site,
]);
// $this->smarty->assign('biaya', $harga);
// $this->smarty->assign('kode_voucher', $voucher);
$this->mportal->selectType();
// $this->smarty->assign("breadcum", $breadcum);
$this->smarty->display("portal/index.html");
}
file model : mPortal.php
class Mportal extends CUTI_Model{
protected $hargaAwal = 350000;
function __construct(){
parent::__construct();
}
function Mportal(){
parent::__construct();
$this->db2->query("SET lc_time_names = 'id_ID'");
}
function getDataVoucher($kodeVoucher){
$data = $this->db2->query("SELECT * FROM tbl_voucher WHERE kode_voucher = '$kodeVoucher' ")->row();
return $data;
}
function getTotalBayar($kodeVoucher = null){
$dataVoucher = $this->getDataVoucher($kodeVoucher);
// if(!$dataVoucher){
// return $this->hargaAwal;
// }
// $totalBayar = ($this->hargaAwal - $dataVoucher->discount);
if($dataVoucher && property_exists($dataVoucher, 'discount')){
$totalBayar = ($this->hargaAwal - $dataVoucher->discount);
} else {
$totalBayar = $this->hargaAwal;
}
return $totalBayar;
}
}
Please or to participate in this conversation.