Warning: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given in C: \ xampp \ htdocs \ modif_pro.php on line 10

0
<?php

    $consulta = consultar($_GET["ruc"]);

    function consultar($ruc_prov){
      include("Conexion.php");
      $s="SELECT * FROM productos WHERE no='".$ruc_prov."' ";
      $rs= mysqli_query($enlace,$s);
      $filas = mysqli_fetch_assoc($rs);
      return [
      $filas["ruc"],
      $filas["direccion"],
      $filas["nombre"]
      ];
    } 
?>

This is my code I do not know because I get that error supposedly it's because I receive that my query is false but this is the value in my database

    
asked by user107431 17.11.2018 в 12:48
source

1 answer

1

there, add a line to your code should work correctly.

in the code you have provided, add a new variable $ rs mysqli_query ($ link, $ rs) or die (mysqli_error)

usually with that code statement causes your query to run correctly, if there is a mysql error, it will throw it to you right there.

$consulta = consultar($_GET["ruc"]);
function consultar($ruc_prov){
include("Conexion.php");
$rs="SELECT * FROM productos  WHERE id='".$ruc_prov."' ";
$rs= mysqli_query($enlace,$rs) or die(mysqli_error($enlace));
$filas = mysqli_fetch_assoc($rs);
return [ $filas["ruc"],$filas["direccion"],$filas["nombre"] ]; 
} 
    
answered by 17.11.2018 в 15:03