giuliano75 Posted June 29, 2015 Share Posted June 29, 2015 I'm having an issue with using $stmt->num_rows in PHP and I'm not sure what I'm doing wrong. $stmt->num_rows is returning 0 when it should be returning 1. The query does work and returns 1 result when executing it in phpMyAdmin. Any help would be greatly appreciated. class usermodel{public function login($email, $password){$query = "SELECT * FROM members WHERE email=? LIMIT 1";$this->dbCon->preparestatement($query);$param_type = "s";$params = array_merge(array($param_type), $email);$tmpArray = array();foreach ($params as $i => $value) {$tmpArray[$i] = &$params[$i];}$this->dbCon->bindParamsToStatement($tmpArray);$this->dbCon->execStartement();$this->dbCon->storeResult();$user_id = 0;$username = '';$db_password = '';$salt = '';$email = '';$this->dbCon->bindResult(array(&$user_id, &$username, &$email, &$db_password, &$salt));$this->dbCon->fetchStartement();$password = hash('sha512', $password . $salt);if ($this->dbCon->numRows()== 1) {class 2:// start statementpublic function preparestatement($statement){`enter code here`$this->_statement = $this->_dbCon->prepare($statement);`enter code here`}public function bindParamsToStatement($params ){call_user_func_array( array( $this->_statement, 'bind_param' ), $params );}public function execStartement(){return $this->_statement->execute();}public function storeResult(){$this->_statement->store_result();}public function bindResult($params){call_user_func_array( array( $this->_statement, 'bind_result' ), $params );}public function fetchStartement(){return $this->_statement->fetch();}public function numRows(){$this->_statement->num_rows;}public function closestartement(){$this->_dbCon->close();} Quote Link to comment https://forums.phpfreaks.com/topic/297097-mysqli-stmt-num_rows-returning-0/ Share on other sites More sharing options...
Ch0cu3r Posted June 29, 2015 Share Posted June 29, 2015 Use return in the numRows method public function numRows() { return $this->_statement->num_rows; } Quote Link to comment https://forums.phpfreaks.com/topic/297097-mysqli-stmt-num_rows-returning-0/#findComment-1515211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.