I have a problem with the following code to print the contents of a database:
$k = $_POST['key'];
$consulta = 'SELECT * FROM ltr WHERE letter_key= $k';
$ejecutar= $conexion->query($consulta);
while ($row = mysqli_fetch_assoc($ejecutar)) {
echo $row['letter'];
echo $row['date'];
}
The problem is that that code throws me the error:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
And I do not know what could be due, because if I modify the query to:
'SELECT * FROM ltr'
I do not get any errors and the result is printed on the screen. Could it be that I'm doing the query incorrectly?