Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7564679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:57:37+00:00 2026-05-30T13:57:37+00:00

i try to use a function but face a problem. I make research on

  • 0

i try to use a function but face a problem. I make research on the Net but there’s no a solution

i have a model . You can see below:

   <?php

class kayitmodel extends CI_Model {

    function User_model() {
        parent::Model();
    }

    function uyeEkle($username, $email, $password, $activationCode) {
        $sha1_password = sha1($password);

        $query = "insert into pasaj_register(username,email,password,activationCode) values(?,?,?,?)";
        $this->db->query($query, array($username, $email, $sha1_password, $activationCode));
    }

    function uyeOnay($registrationCode) {
        $query = "SELECT id FROM pasaj_register where activationCode = '" . $registrationCode . "' and active != 1";
        $result = $this->db->query($query, $registrationCode);

        if ($result->num_rows() == 1) {
            $query = "UPDATE pasaj_register SET active = 1 WHERE activationCode = ?";
            $this->db->query($query, $registrationCode);

            return true;
        } else {
            return false;
        }
    }

     function girisKontrol($username, $password) {
        $sha1_password = sha1($password);
        $query = "SELECT id FROM pasaj_register WHERE username = ? and password = ?";

        $result = $this->db->query($query, array($username, $sha1_password));

        if ($result->num_rows() == 1)
            return $result->row(0)->id;
        else
            return false;
    }



}

In giris controller i use girisKontrol function

<?php

class giris extends CI_Controller {

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

    public function index() {
        $this->load->model('kayit/kayitmodel');
        $this->load->view('giris/giris');
    }


    public function main_page() {

        extract($_POST);


        $userID = $this->giris->kayitmodel($username, $password);


        if(!userID)
            echo "yok";
        else 
            echo "var"; 
    }

}

?>

but when page is processed it gives error :

Fatal error: Call to a member function kayitmodel() on a non-object in C:\xampp\htdocs\pasaj\application\controllers\giris.php on line 20

why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:57:38+00:00Added an answer on May 30, 2026 at 1:57 pm
     $userID = $this->giris->kayitmodel($username, $password);
    

    This is wrong. giris is your controller, it is currently $this. kayitmodel is your model. You then need to call a function on your model.

     $userID = $this->kayitmodel->girisKontrol($username, $password);
    

    Also in your model:

    function User_model() {
        parent::Model();
    }
    

    should be:

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

    EDIT: Models need to start with an uppercase letter, with the rest lowercase. Also the file name should be the class name, but all lowercase.
    Manual: http://codeigniter.com/user_guide/general/models.html

    This should be in a file called kayitmodel.php (note the lowercase ‘k’).

    class Kayitmodel extends CI_Model { // Note the capital 'K'
    

    Your call should be changed to:

    $userID = $this->Kayitmodel->girisKontrol($username, $password); // Note the capital 'K'
    

    EDIT2: Your controller should start with an uppercase letter too.
    Manual: http://codeigniter.com/user_guide/general/controllers.html

    class Giris extends CI_Controller { // Note the capital 'G'
    

    EDIT3: You need to load the model in the constructor of your controller, so all methods inside can use it.

    class Giris extends CI_Controller {
    
        public function __construct() {
            parent::__construct();  // Make sure this is the 1st line in the constructor
            $this->load->model('kayit/kayitmodel');
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a reason why I can use a generic function with different type
I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python
I have a problem with my form when I try to submit with ajax.
I try to put some strings to CharBuffer with CharBuffer.put() function but the buffer
I have a program in which I need to use the Format(); function to
I use function RegisterEventHotKey() and when I try registering Cmd + C or Cmd
I use iconv php function but some characters doesn't convert correctly: ... $s =
I try to run this simple code in node.js: var YUI = require(yui3); YUI.use(function(Y)
I have the following (basically, schedule_box is the wrapper, and there can be as
i have this code: net.requestXHR = function() { this.xhr = null; if(window.XMLHttpRequest === undefined)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.