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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.