Jump to content

mysqli_fetch_array expects parameter 1...


gocart

Recommended Posts

Similar errors have probably been posted before, but i was hoping someone could help me with my specific code since I'm a noob to PHP lol.

Here's the error I'm getting: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in on line 52
 

Here's the code, I've bolded line 52: 

 

<?php

 
if(isset($_POST['search']))
{
    $valueToSearch = $_POST['valueToSearch'];
   $query = "SELECT * FROM `submissions_35` WHERE CONCAT(`id`, `form_id`, `element_label`, `date`, `ip` ) LIKE '%".$valueToSearch."%'";
    $search_result = filterTable($query);
    
}
 else {
    $query = "SELECT * FROM `submissions_35`";
    $search_result = filterTable($query);
}
 
function filterTable($query)
{
    $connect = mysqli_connect("localhost", "", "", "");
    $filter_Result = mysqli_query($connect, $query);
    return $filter_Result;
}
 
?>
 
<!DOCTYPE html>
<html>
    <head>
        <title>PHP HTML TABLE DATA SEARCH</title>
        <style>
            table,tr,th,td
            {
                border: 1px solid black;
            }
        </style>
    </head>
    <body>
        
       <form action="test_data_table.php" method="post">
            <input type="text" name="valueToSearch" placeholder="Value To Search"><br><br>
            <input type="submit" name="search" value="Filter"><br><br>
            
            <table>
                <tr>
                    <th>id</th>
                    <th>Form ID</th>
                    <th>Form Content</th>
                    <th>Submission Date</th>
                    <th>User ip</th>
                </tr>
      <?php while($row = mysqli_fetch_array($search_result)):?>
                <tr>
                    <td><?php echo $row['id'];?></td>
                    <td><?php echo $row['form_id'];?></td>
                    <td><?php echo $row['element_value'];?></td>
                    <td><?php echo $row['date'];?></td>
                    <td><?php echo $row['ip'];?></td>
                </tr>
                <?php endwhile;?>
            </table>
        </form>
        
    </body>
</html>
 
Thank you!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.