I am trying to create a search dependent on what title, artist, or genre is entered.
I keep receiving these errors. Thanks in advance.
Notice: Undefined variable: search_query in H:\Other\Easy PHP\EasyPHP-5.3.9\www\Mobile Application\checksearch.php on line 7
Deprecated: Function eregi() is deprecated in H:\Other\Easy PHP\EasyPHP-5.3.9\www\Mobile Application\checksearch.php on line 7
Error: you have entered an invalid query, you can only use characters!
MY CODE BELOW (Attachment Added)
Number of downloads: 14
<?php session_start();?>
<?php
include 'include/db_config.php';
if (!eregi("[[:alpha:]]", $search_query))
{
echo "Error: you have entered an invalid query, you can only use characters!<br>";
exit; //No need to execute the rest of the script.
}
$query= mysql_query("SELECT * FROM products WHERE title='$search_query'
OR artist='$search_query' OR genre='$search_query' ORDER BY genre");
$result= mysql_numrows($query);
if ($result == 0)
{
echo "Sorry, no matches found ($search_query)";
exit; //No results found, why bother executing the rest of the script?
}
else if ($result == 1)
{
echo "I've found <b>1</b> match!<br>";
}
else {
echo "I've found <b>$result</b> matches!<br>";
}
while ($row= mysql_fetch_array($query))
{
$title= $row["title"];
$artist = $row["artist"];
$genre = $row["genre"];
echo "The title is: $title.<br>";
echo "The artist is: $artist.<br>";
echo "The genre is: $genre.<br>";
}
?>
</body>
</html>

New Topic/Question
Reply




MultiQuote






|