Hello I need help with these lines gives me error and I do not know the reason. First the line:
$registro = mysqli_query("SELECT * FROM productos WHERE nomb_prod LIKE '%$dato%' OR tipo_prod LIKE '%$dato%' ORDER BY id_prod ASC");
I get the following error:
Warning: mysqli_query () expects at least 2 parameters, 1 given in C: \ wamp \ www \ www \ registration \ php \ product_search.php on line 9
Another line that gives me error:
if(mysqli_num_rows($registro)>0){
while($registro2 = mysql_fetch_array($registro)){
echo '<tr>
<td>'.$registro2['nomb_prod'].'</td>
<td>'.$registro2['tipo_prod'].'</td>
<td>S/. '.$registro2['precio_unit'].'</td>
<td>S/. '.$registro2['precio_dist'].'</td>
<td>'.fechaNormal($registro2['fecha_reg']).'</td>
<td><a href="javascript:editarProducto('.$registro2['id_prod'].');" class="glyphicon glyphicon-edit"></a> <a href="javascript:eliminarProducto('.$registro2['id_prod'].');" class="glyphicon glyphicon-remove-circle"></a></td>
</tr>';
}
}
In this case the error is because I have to add a parameter. Well it's just that I'm moving from mysql to mysqli which is quite similar
Connection file:
<?php
const DB_HOST = 'localhost';
const DB_USER = 'root';
const DB_PASSWORD = '';
const DB_NAME = 'tienda';
const DB_CHARSET = 'UTF8';
function database_connect()
{
$conexion=new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
if($conexion->connect_errno){
echo "No conectado";
}else{
}
}
?>