Home » Php » mysql – Warning: mysqli_query() expects parameter 3 to be integer, array given in C:\wamp64\www\FoodStuff\assets\config.php on line 18 or line 21

mysql – Warning: mysqli_query() expects parameter 3 to be integer, array given in C:\wamp64\www\FoodStuff\assets\config.php on line 18 or line 21

Posted by: admin February 25, 2020 Leave a comment

Questions:

1 ) Warning: mysqli_query() expects parameter 3 to be integer, array given in C:\wamp64\www\FoodStuff\assets\config.php on line 18

2) Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\wamp64\www\FoodStuff\assets\config.php on line 21

    // this code is for database connection

    $connect = mysqli_connect('localhost','root','','foodstuff') or die(mysqli_error());
    //$db = mysqli_select_db('foodstuff',$connect);

    function redirect($page){

      echo "<script>window.open('$page.php','_self')</script>";
    }

    function calling_data($table,$where=null){
      $array = [];
      if($where==null){
        $calling = mysqli_query(mysqli_connect('localhost','root','','foodstuff'),"select * from $table");
      }
      else{
        $calling = mysqli_query(mysqli_connect('localhost','root','','foodstuff'),"select * from $table where $where",$array);
      }

        while($row = mysqli_fetch_array($calling , MYSQLI_NUM)){
          $array[] = $row;
        }
        return $array;
    }
    ?>```


How to&Answers: