Welcome Guest, Not a member yet? Register   Sign In
Call to a member function myfunction() on null
#1

Controller/cuzdan.php

PHP Code:
$this->load->model("cuzdan_model"); // Line 39
$data["gelirler"] = $this->cuzdan_model->getParaHareketleri("gelir"); // Line 40
$data["giderler"] = $this->cuzdan_model->getParaHareketleri("gider"); // Line 41

$this->load->view("cuzdan/genelBakis"$data); // Line 43 

models/cuzdan_model.php


PHP Code:
public function getParaHareketleri($islem)
 {
$this->db->select("*")
->
from("parahareketleri")
->
where("islem"$islem)
->
get()
->
resul_array();

This is the ERROR:
Call to a member function getParaHareketleri() on null on line 40

Please help me
Reply
#2

help #1:
http://www.codeigniter.com/user_guide/da...ilder.html

help #2
http://www.codeigniter.com/user_guide/da...sults.html

hint #1
spelling is wrong here: resul_array();
Reply
#3

Which version of CodeIgniter are you using? It sounds like a UCfirst problem if using CI3.
Reply
#4

Codeigniter 3.0.6.. I am using this version of Codeigniter
Reply
#5

Using 3.x, your controller & model filenames need to be UCfirst, eg controllers/Cuzdan.php and models/Cuzdan_model.php
If they aren't, then CodeIgniter will not find the model, and $this->cuzdan_model will be null, which will produce the error message you described.
Reply
#6

my model name is such...
class Cuzdan_Model extends CI_Model{
....
}

after I did like you said...
class Cuzdan_Model extends UC_Model{
....
}

but it didnt work again
Reply
#7

The function in your model isn't returning anything, so the controller doesn't get anything to work with.
Replace the function with this:
PHP Code:
public function getParaHareketleri($islem)
{

 
 $query $this->db->select("*")
 
 ->from("parahareketleri")
 
 ->where("islem"$islem)
 
 ->get();
 
 if ($query->num_rows() > ) {
 
    return $query->result_array();
 
 }
 
 else {
 
    return array();
 
 }


Reply
#8

Nothing is changed Sad
Reply
#9

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class cuzdan extends Admin_Controller {

/*

SQL YAPISI
----------

CREATE TABLE `paraHareketleri` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`tutar` INT(11) NOT NULL DEFAULT '0',
`aciklama` VARCHAR(150) NOT NULL COLLATE 'utf8_turkish_ci',
`tarih` DATETIME NOT NULL,
`islem` VARCHAR(25) NOT NULL COLLATE 'utf8_turkish_ci',
PRIMARY KEY (`id`)
)
COLLATE='utf8_turkish_ci'
ENGINE=MyISAM
;

*/

public function __construct()
{
parent::__construct();

$this->load->model('cuzdan_model');
}

public function index()
{
redirect(base_url('cuzdan/genelBakis'));
}

public function genelBakis()
{

$data["gelirler"] = $this->cuzdan_model->getParaHareketleri("gelir");
$data["giderler"] = $this->cuzdan_model->getParaHareketleri("gider");

$this->load->view("cuzdan/genelBakis", $data);
}

public function paraHareketiEkle()
{
$data["tutar"] = $this->input->post("tutar");
$data["aciklama"] = $this->input->post("aciklama");
$data["tarih"] = date("Y-m-d h:mConfused");
$data["islem"] = $this->input->post("islem");


$sonuc = $this->cuzdan_model->paraHareketiEkle($data);

if ($sonuc == true) {

$this->session->set_flashdata('mesaj', 'Para Hareketi Başarıyla Gerçekleşti.');
}else{

$this->session->set_flashdata('mesaj-hata', 'Para Hareketi Eklerken Bir Sorun Oluştu.');
}

redirect(base_url('cuzdan/genelBakis'));
}
}


This is my controller..
Reply
#10

Did you change the php file name to:
models/Cuzdan_Model.php
Reply




Theme © iAndrew 2016 - Forum software by © MyBB