4

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Phil Bryant
  • 53
  • 1
  • 1
  • 3

1 Answers1

6

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.

hmaxx
  • 597
  • 2
  • 8
  • 18