I just started getting an error this morning on some rented server space from a couple of prepared statements: "Malformed communication packet."
It seems to be happening only on prepared statements. This code has been on the server for years but started throwing errors today.
This simple statement throws the error:
$stmt=$conn->prepare("SELECT RootedID, WeekDate, Qty FROM inventoryrooted");
$stmt->execute();
echo $stmt->error;
$stmt->bind_result($code, $WeekDate, $Qty);
$stmt->store_result();
while($stmt->fetch()){
$stmtInsertRC->execute();
}
$stmt->close();
If I change it to a vanilla connection it works fine:
$sql = "SELECT RootedID, WeekDate, Qty FROM inventoryrooted";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$code = $row["RootedID"];
$WeekDate = $row["WeekDate"];
$Qty = $row["Qty"];
$stmtInsertRC->execute();
}
I've got hundreds of prepared statements in the website that are working fine. This seems to be happening on a couple of tables only. Coincidentally, I've opened both of these tables this morning in Navicat to get a look at the data... Not sure if that could have corrupted them? I've tried repairing the table, making a fresh copy and restoring the table. I've also asked the site admin to restart MariaDB (still waiting on that).
Does anyone have any suggestions on where I should be looking for a solution? Am I barking up the wrong tree?
10.3.26-MariaDB
PHP 7.2.34
Your woes are most likely caused by your host's upgrade to MariaDB 10.3.26, released yesterday. See MDEV-24121 for more information. I haven't yet heard a good explanation, but reports claim that downgrading MariaDB, upgrading PHP to 7.3, or enabling PDO take care of this for now.
I believe that adding this to your code would enable prepared-statement emulation:
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);