0

I keep getting the following error:

[21-Apr-2020 21:26:33 UTC] PHP Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in

Here is the code I have in PHP

    $stmt = $mysqli->prepare('SELECT id, name FROM accounts AS acc INNER JOIN inventory AS inv ON acc.id=inv.id INNER JOIN itemdefinition AS def ON def.id=inv.id WHERE acc.name=?');
    $stmt->bind_param("s", $name);
    if($stmt->execute() === TRUE) {
        echo 'Correct select statement.';
    } else {
        echo 'Something wrong with the select statement';
    }

How my databases are setup enter image description here

enter image description here enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    You are not checking the return value of `prepare`. It is probably `false` (which is a boolean value), indicating an error in your statement syntax most likely. Use `mysqli_report(MYSQLI_REPORT_ALL);` before it to turn on error reporting for it and see what the real issue is. – CherryDT Apr 21 '20 at 21:38
  • SUGGESTIONS: Check the return values of both [$mysqli->prepare()](https://www.php.net/manual/en/mysqli.prepare.php) and [$stmt->bind_param()](https://www.php.net/manual/en/mysqli-stmt.bind-param.php). Also check the value of `$name`. In particular, make sure that "$name" *HAS* a value; a *string* value. – FoggyDay Apr 21 '20 at 21:45
  • Thanks guys, i was missing acc. infrom of the stuff i was selecting – Nighel Nijhuis Apr 21 '20 at 21:55
  • Relevant [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Apr 21 '20 at 23:09

0 Answers0