Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to a member function bind_param() on boolean error in PHP-->MySQL [duplicate]

Tags:

php

mysql

mysqli

My code is as follows:

include('config.php');

$mysqli = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);

$statement = $mysqli->prepare("INSERT INTO brickTable (url, description) VALUES(?,?)");

$statement->bind_param("ss", $_POST["url"], $_POST["description"]);

I keep getting the error "Call to a member function bind_param() on boolean". I've looked all over S.O., and found several examples, but none that solved my issue. I don't see any syntax or typo errors in my code. Using a var_dump, I know that the $_POST["url"] and $_POST["description"] exist and are being received properly.

Thoughts or help?

like image 969
Phil Bryant Avatar asked Sep 13 '25 17:09

Phil Bryant


1 Answers

First turn on error reporting by adding the below two lines at the top of your page. Then try printing out the exact error by doing echo $mysli->error;

error_reporting(E_ALL);
ini_set('display_errors', 1);

$mysqli = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
$statement = $mysqli->prepare("INSERT INTO brickTable (url, description) VALUES(?,?)");
echo $mysqli->error;
$statement->bind_param("ss", $_POST["url"], $_POST["description"]);
$statement->execute();

It will tell you the error.

like image 136
hmaxx Avatar answered Sep 15 '25 09:09

hmaxx