Call to a member function myfunction() on null |
Controller/cuzdan.php
PHP Code: $this->load->model("cuzdan_model"); // Line 39 models/cuzdan_model.php PHP Code: public function getParaHareketleri($islem) Call to a member function getParaHareketleri() on null on line 40 Please help me
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();
Which version of CodeIgniter are you using? It sounds like a UCfirst problem if using CI3.
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.
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
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)
<?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:m"); $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.. |
Welcome Guest, Not a member yet? Register Sign In |