View Full Version : Can you check the error inside?

10-10-2004, 09:01 AM
Hi everyone!! :cool:
I have just written a piece of code..
it has error but I don't know that the error is from php or mysql connection
here is the source:
<title>Film Search Result</title>

<h1>Film Search Results</h1>
if (!$searchterm||!$searchtype)
echo "You have not entered search details. Please go back and try again.";
@ $db= mysql_connect("localhost");
if (!$db)
echo "Error: Could not connect to databases. Please try again later.";
$query="SELECT* FROM film WHERE ". $searchtype. "like '%".$searchterm. "%'";
$result= mysql_query($query);
echo "<p>Number of films found: ".$num_results."</p>";
for ($i=0; $i<$num_results; $i++)
$row= mysql_fetch_array($result);
echo "<p><strong>".($i+1).".Title:";
echo htmlspecialchars(stripslashes($row["title"]));
echo "</strong><br />Director: ";
echo htmlspecialchars(stripslashes($row["director"]));
echo "<br />Presenting Date:";
echo htmlspecialchars(stripslashes($row["presentingdate"]));

by the way, can you show me how to put the code in a separate bounded text area..Because it's not so clear to see when I just copy and paste my code like this. :D

10-10-2004, 11:46 AM
What is the error you are receiving?

10-10-2004, 03:37 PM
I create a Javacript page to receive the key word form user ( the searchtype: is to fix the type of searching( title, director, date)
the searchterm is used to search for description that contain the search term..
the table film I created include :title, presentingdate, director..and so on..I think I declared an keyed in data correctly.. :p
When I click the submit button on the Javacript page, it links to the result.php , but in this page, it just displays as follow:
/*Film Search Results
"; for ($i=0; $i<$num_results; $i++) { $row= mysql_fetch_array($result); echo "
".($i+1).".Title:"; echo htmlspecialchars(stripslashes($row["title"])); echo "
Director: "; echo htmlspecialchars(stripslashes($row["director"])); echo "
Presenting Date:"; echo htmlspecialchars(stripslashes($row["presentingdate"])); echo"

"; } ?>
:confused: Can you help me!!