I know that I'm using multiple PHP styles, but I don't know how can I set this.
I think that there something wrong in exit(); and I don't know what to do to get the desired result.
<?php $mysqli = new mysqli("localhost", "root", "", "search"); if(isset($_GET['search_button'])) { $search = $_GET['search']; if(search=="") { echo "<center> <b> Please write something in Search Box </b> </center>" exit(); } $sql = "select * from website where site_key like '%$search%' limit 0, 5"; $rs = mysql_query($sql); if(mysql_num_rows($rs)<1) { echo "<center> <h4> <b> Oops !!! Sorry, there is no result found to related the word. </b> </h4> </center>"; exit(); } echo "<font size='+1' color='#1a1aff'> images for $search</font>"; while($row = mysql_fetch_array($rs)) { echo "<td> <table style='margin-top: 10px'> <tr> <td> <img src='img/$row[5]' height='100px'> </td> </tr> </table> </td>" } } ?>
mysqliandmysql- that doesn't work. Please stop using themysql_*driver, its outdated and not longer supported in PHP7. Usemysqli_*only instead, then your code will work. Simply adapt your querys, oh and btw have a look at bobby-tables.com and learn something about SQL injection. With this code your database can be hacked in a few seconds without any need of deep knowledge about databases.. simply SQL injection would work perfectly on this one.echo "<center> <b> Please write something in Search Box </b> </center>"misses a;at the end.