php - mysqli_num_rows() Error -


i passing $query"update...", has no errors, query method. have checked other posts point query not appear problem.

   public function query($sql) {         $this->_result = mysqli_query($this->_link, $sql);         $this->_numrows = mysqli_num_rows($this->_result);       }     $db->numrows(); 

i receiving error 'mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in...', said there nothing wrong query, _numrows returning correct value numrows() method returns _numrows, returning error. ideas appreciated. thanks.

"i passing update query.."

read documentation mysqli::query:

returns false on failure. successful select, show, describe or explain queries mysqli_query() return mysqli_result object. for other successful queries mysqli_query() return true.

hence no rows returned (which mysqli_num_rows does). you're looking mysqli::$affected_rows instead (that shows how many rows affected - not how many rows returned):

$this->_numrows = $this->_link->affected_rows; 

or

$this->_numrows = mysqli_affected_rows($this->_link); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -