Linked question is here.
I have upgraded the code in the linked question to use a prepared statement.
I now have:
$stmt = $conn->prepare("INSERT INTO `workbook-data` (`workbook-language`, `gui-language`, `foreign-language-group-mode`, `version`) VALUES (?, ?, ?, ?)");
$stmt->bind_param('ssis', $mwblang, $guilang, $flgmode, $version);
$mwblang = mysqli_real_escape_string($conn, $_GET['mwblang']);
$guilang = mysqli_real_escape_string($conn, $_GET['guilang']);
$flgmode = mysqli_real_escape_string($conn, $_GET['flg']);
$version = mysqli_real_escape_string($conn, $_GET['version'] ?? '210061');
if ($stmt->execute()) {
echo "<br>" . "New record created successfully";
} else {
echo "Error: " . mysqli_error($conn);
}
$stmt->close();
According to the documentation for bind_param
it states this about the return value:
Returns true on success or false on failure.
In these official examples they don't seem to do any error checking for failure. Should be we testing the return value? I have done so for execute()
but I am not sure how much checking is needed.