Good day!
I'm doing an autocomplete for an input in ajax through php and mysql, the tutorial here if you want to see it
the php adapting it to my database
<?php
require('conectar.php');
$keyword = strval($_POST['query']);
$search_param = "{$keyword}%";
$sql = $conexion->prepare("SELECT distinct nombre_cliente FROM cuentas WHERE nombre_cliente LIKE '%".$_POST["query"]."%' ORDER BY nombre_cliente ASC");
$sql->bind_param("s",$search_param);
$sql->execute();
$result = $sql->get_result();
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc()) {
$resultado_nombre_cliente[] = $row["nombre_cliente"];
}
echo json_encode($resultado_nombre_cliente);
}
$conexion->close();
?>
Uncaught Error: Call to undefined method mysqli_stmt :: get_result () in /home2/gabriel/perezrodriguezabogados.com/sistema/PHP/autocompletar.php:8
I've read that you have to install something from a controller but I'm using cpanel in a common hosting account, in this case hostgator and I do not know if you can do that
Is there another way to write it and that I do what is required?
I leave the script in case, although I do not think it's necessary
$(document).ready(function () {
$('#input_nombre_cliente').typeahead({
source: function (query, result)
{
$.ajax({
url: "../PHP/autocompletar.php",
data: 'query=' + query,
dataType: "json",
type: "POST",
success: function (data)
{
result($.map(data, function (item) {
return item;
}));
}
});
}
});
});