I'm having trouble getting this php script working with mysqli. I'm using Apache server, PHP 5.5, mysqli. The connection works, and I have other statements working properly (not with bind though).
// NOTE: servername, username, password defined but not shown
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
// database connection error
echo '1';
$conn->close();
exit();
}
$sqlQuery = "INSERT INTO 'fishingusers' SET 'deviceID' = ?, 'nickname' = ?, 'valid_on' = 'NOW()', 'valid_until' = 'null'";
echo ' '. $sqlQuery . '';
$deviceID = $conn->real_escape_string($_GET['deviceID']);
$nickname = $conn->real_escape_string($_GET['nickname']);
$stmt = $conn->prepare($sqlQuery);
$stmt->bind_param('ss', $deviceIDValue, $nicknameValue);
$deviceIDValue = $deviceID;
$nicknameValue = $nickname;
if($stmt->execute()) {
// insert success
echo '0';
}
else {
// insert failed
echo '3';
}
$conn->close();
I am receiving this error:
Fatal error: Call to a member function bind_param() on a non-object in XXXX on line 27
Line 27 is the $stmt->bind_param()
. Sorry, I'm very new to PHP... this seems pretty simple.