Jump to content

Recommended Posts

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 statement
public 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();
}

Link to comment
https://forums.phpfreaks.com/topic/297097-mysqli-stmt-num_rows-returning-0/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.