Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to a member function on a non-object
#1

[eluser]Gwarrior[/eluser]
I'm fairly new to CI, but using the MVC approach, I keep getting this error.

Fatal error: Call to a member function on a non-object

In which it is referring to the Model below.

Code:
function insert_item() {
         $this->load->database();
        $itemname = $this->input->post('itemname');
        $price = $this->input->post('price');
        $details = $this->input->post('details');
        $paypal = $this->input->post('paypal');
        $image = $this->input->post('image');
        $query = $this->db->query("INSERT INTO products (itemname, price, details, paypal, image) VALUES ('$itemname', '$price', '$details', '$paypal', '$image')");
        if ($query->num_rows() > 0) {
            echo 'Item Added to the Catelog.';
        } else {
            echo 'Item NOT Added to the Catelog.';
        }
    }

The specific line is
Code:
if ($query->num_rows() > 0) {

Anyone know why? Thanks!
#2

[eluser]GSV Sleeper Service[/eluser]
just a guess, but INSERT does not return any rows... try
Code:
if($this->db->affected_rows()){...}




Theme © iAndrew 2016 - Forum software by © MyBB