Php Fatal Error Call To A Member Function Num_rows
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this fatal error: call to a member function num_rows() on boolean site About Us Learn more about Stack Overflow the company Business Learn call to a member function result() on a non-object in codeigniter more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x call to a member function num_rows() on array Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Call
$query->num_rows()
to a member function num_rows() on a non-object in model file up vote 0 down vote favorite This is my code in model.. function get_info($product_id) { $this->db->from('product'); $this->db->where('product_id',$product_id); $query = $this->db->get(); if($query->num_rows()==1) { return $query->row(); } So many questions on stackoverflow but I Dont found any answer related to scenario. So what I am doing wrong?? php mysql codeigniter share|improve this question asked Dec call to a member function result_array() on a non-object in 26 '14 at 7:46 Kedar B 4331726 Please check type of $query. I think it is returning false. and you are trying ->num_rows() on false. Also check if you are typing table name 'product' and field name 'product_id' correctly –Maulik Vora Dec 26 '14 at 7:50 2 Try to check using echo $query->num_rows(); first & then check result. And also check query is working properly .... –Anand Solanki Dec 26 '14 at 7:53 Does db::get() return an object? What does echo gettype($db); tell you? Haven't used CodeIgniter but let us know what the type of $query is an it'll give a little more insight. –wiliam.orazi Dec 26 '14 at 7:59 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote accepted Your query is probably failing. Make sure database debugging in on and modify your code: if ($query !== FALSE) { // Run your code if ($query->num_rows() === 1) { return $query->row(); } } else { // Check error echo 'Database Error(' . $this->db->_error_number() . ') - ' . $this->db->_error_message(); } share|improve this answer answered Dec 26 '14 at 20:35 versal
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings fatal error call to a member function num_rows() on boolean in codeigniter and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; http://stackoverflow.com/questions/27654328/call-to-a-member-function-num-rows-on-a-non-object-in-model-file it only takes a minute: Sign up Fatal error: Call to a member function num_rows() on a non-object [duplicate] up vote -1 down vote favorite This question already has an answer here: Reference - What does this error mean in PHP? 29 answers Hihow r u all? I m trying to calculate basic salary with Particular employee_id but when i http://stackoverflow.com/questions/5846846/fatal-error-call-to-a-member-function-num-rows-on-a-non-object m trying to .. give me fatal error.. Fatal error: Call to a member function num_rows() on a non-object in D:\wamp\www\template\application\models\salary.php on line 112 my code is: model db->from('salary_scale'); $this->db->where('id',$salary_id); $this->db->where('deleted',0); $query = $this->db->get(); return ($query->num_rows()==1); } /* Determines if a given employee_id is a employee */ function exists_employee($employee_id) { $this->db->from('grade_history'); $this->db->where('employee_id',$employee_id); $query = $this->db->get(); return ($query->num_rows()==1); } /* Returns all the suppliers */ function get_all() { $this->db->from('salary_scale'); $this->db->where('deleted', 0); $this->db->order_by("name", "asc"); return $this->db->get(); } /* * * Gets information about a particular employees salary */ function grade_rules_info($salary_grade) { $this->db->from('salary_scale_rules'); $this->db->where('salary_grade',$salary_grade); $query = $this->db->get(); if($query->num_rows()==1) { return $query->row(); } else { //Get empty base parent object, as $item_id is NOT an item $salary_obj=new stdClass(); //Get all the fields from items table $fields = $this->db->list_fields('salary_scale_rules'); foreach ($fields as $field) { $salary_obj->$field=''; } return $salary_obj; } } /* * * Gets information about a particular employees salary */ function get_info($employee_id) { $this->db->from('allowance'); //$this->db->join('deductions', 'deductions.eid = allowance.eid'); $this->db->where('employee_id',$employee_id); $query = $this->db->get(
here for a quick overview of the site Help Center Detailed answers to http://stackoverflow.com/questions/14871213/code-igniter-call-to-a-member-function-num-rows-on-a-non-object any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow call to Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Code igniter : Call to a member function num_rows() on a non-object up vote 3 down vote favorite i have developed a app in codeigniter on call to a localhost ...the app works fine .. then i uploaded the app into temporary server ... and after login into the admin panel i am getting this error..but if i run the same app in localhost it works fine ... error Fatal error: Call to a member function num_rows() on a non-object in /home/u520606051/public_html/application/models/loginmodel.php on line 9 this my Model : function validate($data) { $query = $this->db->get_where('users', $data); if($query->num_rows() == 1) { return true; } } controller function verifyUser() { //getting parameters from view $data = array( 'username' => $this->input->post('username'), 'password' => $this->input->post('password') ); $this->load->model('loginModel'); $query = $this->loginModel->validate($data); if ($query) { //if the user c validated //data variable is created becx we want to put username in session $data = array( 'username' => $this->input->post('username'), 'is_logged_in' => true ); $this->session->set_userdata($data); redirect('sessionController/dashboard_area'); } else { $this->index(); } } file name Of Modal: loginmodel.php class Loginmodel extends CI_Model file name of Controller loginController.php class LoginC