php | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

php

<div class="search"> <form name="f1" method="post" action="search.php"> <input type="search" name="search_q"/> <input type="submit" value="Поиск"/> </form> </div> <?php $search_q=$_POST['search_q']; $l= mysqli_connect('localhost', 'root', '12345', 'hova'); $search_q = trim($search_q); $search_q = strip_tags($search_q); $q= mysqli_query($l, "SELECT * FROM hova WHERE LIKE '%$search_q%'"); $itog=mysqli_fetch_assoc($q); while ($itog = mysqli_fetch_assoc($q)) { printf("%s (%s)\n",$r["name"],$r["content"]); } mysqli_free_result($q); mysqli_close($l); ?> //gives an error message:Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given

3rd Oct 2018, 3:50 PM
Алексей Кузьминых
Алексей Кузьминых - avatar
2 Answers
+ 2
Use mysqli_num_rows() to get the results
3rd Oct 2018, 6:52 PM
Femi
Femi - avatar
+ 1
thank you
3rd Oct 2018, 7:49 PM
Алексей Кузьминых
Алексей Кузьминых - avatar