This question already has an answer here:
I hate to ask this question but I have searched and searched and done all sorts of things to see if I can resolve on my own.
Call to a member function bind_param() on a non-object
var_dump = bool(false)
$stmt = $mysqli->prepare("INSERT INTO resetPswd (userID,key,date,status) VALUES (?,?,NOW(),0)");
$stmt->bind_param('is', $userID,$key);
$stmt->execute();
I have removed everything then added all back the problem lies with "key", it works until I add that in.
I am creating a random 'key':
$key = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
db = key - varchar(12)
Any help would be great! Why am I using mysqli? It's required.
</div>
That error means that the call to $mysqli->prepare returned something that isn't an object, my guess would be it returns something like "false" which is not an object and thus you can't call "bind_param" on false. Doesn't sound like $key has anything to do with it.
KEY
is a reserved word in MySQL.
You must escape it with backticks in order to use it as column name.
$stmt = $mysqli->prepare("INSERT INTO resetPswd (userID,`key`,date,status)
VALUES (?,?,NOW(),0)");
From the PHP documentation:
If the database server successfully prepares the statement, PDO::prepare() returns a PDOStatement object. If the database server cannot successfully prepare the statement, PDO::prepare() returns FALSE or emits PDOException (depending on error handling).
http://php.net/manual/en/pdo.prepare.php#refsect1-pdo.prepare-returnvalues
You have an error in your query. key
is a reserved word and will make that statement return false