Hello,
I am selecting information from a database based on form results.
<?php
$type = $_POST['type'];
$search = $_POST['search'];
$dbcnx = mysql_connect("localhost", "username", "password");
mysql_select_db("database");
$result = mysql_query("SELECT * FROM news WHERE $type='$search'");
if ($result == "")
{
print "We could not find a match for the search query $search in the search type: $type";
exit();
} else {
while ($row = mysql_fetch_array($result) ) {
$msgid = $row["msgid"];
$author = $row["poster"];
$message = $row["message"];
$title = $row["title"];
print "$title / $message / $author<br> ";
}}
?>
It displays information if it finds it, but it doesn’t show the error if nothing is found. What is wrong with the
if ($result == "")
{
print "We could not find a match for the search query $search in the search type: $type";
exit();
}
?
Thanks!