php - Error with mysqli->prepare - Malformed communication packet
one text
My code was working fine, but today I am getting this error using mysqli-prepare "Malformed communication packet"
Code:
<?php
require_once('conntele.php');
$sql_type = "SELECT id_tipo_identificacion, descripcion FROM tipo_identificacion WHERE estado_registro = 'A'";
echo "Using Mysqli->query<br>";
if ($res_type = $mysqli->query($sql_type)) {
while($row_type = $res_type->fetch_assoc()){
echo "type: ".$row_type['id_tipo_identificacion']." description: ".$row_type['descripcion']."<br>";
}
}
echo "<br>";
echo "Using Mysqli->prepare<br>";
if ($stmt = $mysqli->prepare($sql_type)) {
$stmt->execute();
$result_type = $stmt->get_result();
print_r($stmt);
while($row_type_iden = $result_type->fetch_assoc()){
echo "type: ".$row_type_iden['id_tipo_identificacion']." description: ".$row_type_iden['descripcion']."<br>";
}
$stmt->close();
}
$mysqli->close();
?>
Error:
Using Mysqli->query
type: 1 description: RUC
type: 2 description: Cedula
type: 3 description: Pasaporte
type: 4 description: Venta a Consumidor Final
type: 5 description: Identificacion del Exterior
Using Mysqli->prepare
mysqli_stmt Object ( [affected_rows] => -1 [insert_id] => 0 [num_rows] => 0 [param_count] => 0 [field_count] => 2
[errno] => 1835 [error] => Malformed communication packet [error_list] =>
Array ( [0] => Array ( [errno] => 1835 [sqlstate] => HY000 [error] => Malformed communication packet ) )
[sqlstate] => HY000 [id] => 57 )
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean in
/prepare.php:17 Stack trace: #0 {main} thrown in
/prepare.php on line 17
PHP Version 7.2.29
How can I solve this problem
Source