PHP mysqli_fetch_assoc() isn't working and no error message

Hello,
I’m fetching rows from my MySqli database and the fetch_assoc() / mysqli_fetch_assoc() function isn’t working.
My code:

    $stmtnota = $conn->prepare('SELECT * FROM nota WHERE Factuurnummer = ?');
    $stmtnota->bind_param('i', $factuurnummer);
    $stmtnota->execute();
    $resultnota = $stmtnota->get_result();
    if(!$rownota = $resultnota->fetch_assoc()) {
        echo 'Fail';
    }

It’s not working. I see ‘Fail’.
But there’s no error message. The preparing, binding and executing of the query is going seemless.
Except the fetching of the rows. I don’t know.
I’ve tried echo error_get_last();, but that doesn’t give any errors.
I don’t get any errors at all…
But still it doesn’t work for some reason.

Can anyone help me?
With kind regards,

How many rows does your query return?

I also wonder whether some parentheses might help:

if(!($rownota = $resultnota->fetch_assoc())) {

Also note that get_result() only works with the MySQL native driver according to the documentation, I don’t know if this is relevant to your configuration.

fetch_assoc isn’t a part of stmt. You’ll need to use fetch() instead.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.