I have the following SQL function, and I have delare the $row in the mysqli_stmt_bind_result.
//get the user number per month
public function chartwaitinguservsproduct(){
$stmt = mysqli_prepare($this->connection,
"select
(Select COUNT(*) from reusematching.waitinglist_product) as COUNTP,
(Select COUNT(*) from reusematching.waitinglist_user) as COUNTU;
");
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_fetch($stmt);
mysqli_stmt_bind_result($stmt, $row->COUNTP, $row->COUNTU);
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
but not matter how I change the Database, the $rows always NULL.
Why? because of the fetch statement??
Why are you using
$rowin one place (the bind) and returning$rows?Don’t you think that might be a bad idea, unless your PHP interpreter is far more advanced than the ones I’ve seen, and able to automatically associate singular and plural variable names 🙂
And, from memory, I think you should probably bind the variables before trying to fetch from them. Again, if your PHP is advanced enough, I suppose it could do some form of temporal manipulation, but I wouldn’t bet money on it.
Sorry, that’s the Australian humour coming through but if you examine the fetch page, it states quite clearly:
I’ll assume for now that the
row/rowsissue was just a typo in your question. If it wasn’t, then that will need fixing as well.