1
votes

Help:

I have error:

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'periode'

Filename: models/k3m.php

Line Number: 32

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'bulan'

Filename: models/k3m.php

Line Number: 33

Fatal error: Call to a member function row() on a non-object in C:\LaporBOS\htdocs\laporbos3\application\modules\laporan_k3\models\k3m.php on line 39

    function saldo_bank($param) {
    $periode = $param['periode'];
    $bulan = $param['bulan'];
    $bulan = $this->get_bulan2($periode,$bulan);
    $sql="SELECT IFNULL( SUM(IFNULL(jumlah_debet,0) ),0) - IFNULL( SUM(IFNULL(jumlah_kredit,0) ),0) AS saldo
            FROM buku_bank
            WHERE YEAR(tanggal) =".$this->session->userdata("tahun_anggaran")." 
            AND MONTH(tanggal) < $bulan";
    $data = $this->db->query($sql)->row();
    return $data->saldo;
}
2
$param param is a string but you treating it like an array. - Musa
var_dump($param) if type is array then The problem is you have no periode,and bulan key, if the type is string there you have it. - tomexsans

2 Answers

0
votes

This is occurring because you are calling row() before you have called result(), so change this

$data = $this->db->query($sql)->row();

to this

$data = $this->db->query($sql)->result()->row();
0
votes

The offset inside the array you passed is not available try to check that does the array you pass has the offset you called and set it to variable. check your $param array do write this at the top of your function

echo "<pre>";
print_r($param); exit;

and than see

$periode = $param['periode'];

that "periode" or "bulan" is exist inside the array or not.