gocart Posted September 22, 2017 Share Posted September 22, 2017 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! Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 22, 2017 Share Posted September 22, 2017 Your query likely failed. Have you checked to see if MySQL is throwing errors? http://php.net/manual/en/mysqli.error.php 1 Quote Link to comment Share on other sites More sharing options...
gocart Posted September 22, 2017 Author Share Posted September 22, 2017 Thanks for the quick reply cyber, you were right, there was an issue with the query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.