I'm trying to show some data in my browser from the database and when I run it it shows me the following error:
mysqli_error () expects parameter 1 to be mysqli, null given
I would appreciate some help.
Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>
<body>
<table border='1px'>
<tr>
<td class='fila'>id</td>
<td class='fila'>Nombre</td>
<td class='fila'>Apellido</td>
</tr>
<?php
$host="localhost";
$usuario="php";
$password="prueba";
$basedatos="clientes";
$connection = mysqli_connect($host,$usuario,$password);
function showerror( ) {
die("Se ha producido el siguiente error: " . mysqli_error($connection));
}
// Seleccionar la base de datos
if (!(@ mysqli_select_db($basedatos, $connection)))
showerror( );
$SQL=" SELECT id_cliente,nombre,apellido FROM clientes.datos where
fecha_creacion between '2018-06-15' and '2018-06-01' ";
if (!($result1 = @ mysqli_query ( $SQL, $connection)))
showerror( );
while ($row1 = mysqli_fetch_row($result1)) {
print("<tr>");
print("<td class='fila'>".$row1[0]."</td>");
print("<td class='fila'>".$row1[1]."</td>");
print("<td class='fila'>".$row1[2]."</td>");
print("</tr>");
}
?>
</body>
</html>