Так лучше?
$searchtype=isset($_GET['searchtype']) ? htmlspecialchars($_GET['searchtype']) : '';
$searchterm=isset($_GET['searchterm']) ? htmlspecialchars($_GET['searchterm']) : '';
$searchterm = trim ($searchterm);
if (!get_magic_quotes_gpc())
{
$searchtype = addslashes ($searchtype);
$searchterm = addslashes ($searchterm);
}
@ $db = new mysqli ('****', '***', '***', '***');
if (mysqli_connect_errno())
{
echo 'Ошибка базы данных.';
exit;
}
$query="SELECT DISTINCT * FROM ".$searchtype." WHERE ".$searchtype." LIKE '%".$searchterm."%'";
$result = $db -> query($query);
if(!empty($result))
{
while($row=mysqli_fetch_array($result))
{
echo $row[$searchtype]."\n";
}
break;
}