0
I am creating a user search system on my website. However I am facing the following error:
This is the code I’m using:
<body>
<h2>Resultados da tua pesquisa</h2><br />
<?php
$query = $_GET['query'];
$min_length = 3;
if (strlen($query) >= $min_length) {
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM usuario WHERE (`nome` LIKE '%".$query."%')") or die(mysql_error());
if (mysql_num_rows($raw_results) > 0) {
echo "<br /><br />";
while ($results = mysql_fetch_array($raw_results)) {
echo '<a href="perfil.php?id='.$results["id"].'" nome="p"><br /><p nome="p"><h3>'.$results["nome"].' '.$results["apelido"].'</h3></p><br /></a><br /><hr /><br />';
}
}else{
echo "<br /><h3>Não foram encontrados resultados...</h3>";
}
}else{
echo "<br /><h3>Tens de escrever pelo menos 3 letras...</h3>";
}
?>
</body>
The error points to line 17, which in the case, in the code snippet above would be line 4. How can I resolve this error and present the search result correctly?
+1 It is another solution, but I have never used it. I believe that the
isset ()
can serve better. : S– Inkeliz