The script works fine if there are results to display
Code: Select all
<?php
if ($_GET['c'] != 1)
{
?>
<form name="form1" action="search2.php" method="GET">
<input type="hidden" name="c" value="1">
<input name="search" type="text" id="search" value="Enter search here" size="50">
<input type="submit" value="Search!">
</form>
<?php
} else if ($_GET['c']==1) {
$dbcnx = @mysql_connect("localhost", "root",
"mypasswd");
//Variable with database connection created
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}//Error message set
//Selecting correct database
if (! @mysql_select_db("jamesforum_uk_db") ) {
echo( "<p>Unable to locate the joke " .
"database at this time.</p>" );
exit();
}
$result = @mysql_query("SELECT * FROM ansr_info WHERE answer LIKE '$search'");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
while ( $row = mysql_fetch_array($result) ){
if (!$result) {
echo ("Sorry, no answer");
}
$answer = $row["answer"];
echo ("The answer to your question is: " . $answer . "<P>");
}
}
?>Thanks for any help - James