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 fatal error: call to a member function num_rows() on boolean in workings and policies of this site About Us Learn more about Stack
Call To A Member Function Result() On A Non-object In Codeigniter
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions call to a member function num_rows() on array Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join call to a member function result_array() on a non-object in them; it only takes a minute: Sign up Call 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.
$query->num_rows()
So what I am doing wrong?? php mysql codeigniter share|improve this question asked Dec 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 $
here for a quick overview of the site Help Center Detailed answers to any questions you call to a member function num_rows() on null 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 Community Stack Overflow is a community of 4.7 http://stackoverflow.com/questions/27654328/call-to-a-member-function-num-rows-on-a-non-object-in-model-file 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 localhost ...the app works fine .. then i uploaded the app http://stackoverflow.com/questions/14871213/code-igniter-call-to-a-member-function-num-rows-on-a-non-object 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 LoginController extends CI_Controller php sql database codeigniter session share|improve this question edited Feb 14 '13 at 10:07 asked Feb 14 '13 at 9:
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 site About Us http://stackoverflow.com/questions/36113195/fatal-error-call-to-a-member-function-num-rows 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 https://github.com/bcit-ci/CodeIgniter/issues/2074 Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Fatal error: Call to a member function call to num_rows() [duplicate] up vote -1 down vote favorite This question already has an answer here: Reference - What does this error mean in PHP? 29 answers This is my code in model.. function installed(){ $query_str = "SHOW TABLES"; $query = $this->db->query($query_str); if($query->num_rows() == 0){ redirect('install'); } } So many questions on StackOverflow but I haven't found any answer related to scenario. So what I am doing wrong? call to a php share|improve this question edited Mar 20 at 11:38 Qirel 2,79851325 asked Mar 20 at 11:36 nisha 74 marked as duplicate by decezephp Users with the php badge can single-handedly close php questions as duplicates and reopen them as needed. Mar 20 at 13:33 This question was marked as an exact duplicate of an existing question. num_rows is not a function, it's a variable. Try $query->num_rows instead. –Qirel Mar 20 at 11:39 @Qirel No I'm using PDO it will be a function i think –nisha Mar 20 at 12:30 num_rows is a mysqli_ variable, not a PDO one. Try $query->rowCount(), but that function might not always work with all databases. Read the documentation. –Qirel Mar 20 at 12:32 Okay thanks.... –nisha Mar 20 at 16:07 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote I would assume that, your $this->db is a mysqli instance. Hence, making a ->query(...) call should gives you a mysqli_result instance on success. So your $query should simply be a mysqli_result object, and hence num_rows should be a property, not a function at all. You are using it wrong. Check here: http://php.ne
Sign in Pricing Blog Support Search GitHub This repository Watch 1,638 Star 13,154 Fork 6,508 bcit-ci/CodeIgniter Code Issues 48 Pull requests 32 Projects 0 Wiki Pulse Graphs New issue Fatal error: Call to a member function num_rows() on a non-object in system/libraries/Session/drivers/Session_cookie.php on line 460 #2074 Closed ghost opened this Issue Dec 15, 2012 · 5 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 1 participant ghost commented Dec 15, 2012 I just migrated my dev site to the development branch and I am getting the following error: Fatal error: Call to a member function num_rows() on a non-object in system/libraries/Session/drivers/Session_cookie.php on line 460 It was working fine with the stable branch. Here is my current DB and Session configs: $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'mysql:host=hostname.com', 'username' => 'MY_USERNAME', 'password' => 'MY_PASSWORD', 'database' => 'MY_DATABASE', 'dbdriver' => 'pdo', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => FALSE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_unicode_ci', 'swap_pre' => '', 'autoinit' => TRUE, 'encrypt' => TRUE, 'compress' => TRUE, 'stricton' => TRUE, 'failover' => array() ); $autoload['libraries'] = array('database', 'form_validation'); $autoload['drivers'] = array('session'); $config['encryption_key'] = 'MY_KEY'; $config['sess_driver'] = 'cookie'; $config['sess_valid_drivers'] = array(); $config['sess_cookie_name'] = 'ci_sid'; $config['sess_expiration'] = 21600; $config['sess_expire_on_close'] = TRUE; $config['sess_encrypt_cookie'] = TRUE; $config['sess_use_database'] = TRUE; $config['sess_table_name'] = 'MY_TABLE'; $config['sess_match_ip'] = TRUE; $config['sess_match_useragent'] = TRUE; $config['sess_time_to_update'] = 300; $config['cookie_prefix'] = ''; $config['cookie_domain'] = '.sub.domain.com'; $config['cookie_path'] = '/'; $config['cookie_secure'] = TRUE; $config['cookie_httponly'] = TRUE; If you need anymore info just ask. Also on a side note, how do I access the nightly user manual? When I try to go to it from a Google search I get redirected away from it. Thank you in advance. narfbg added a commit that closed this issue Dec 17, 2012 narfbg