Hi everyone!!
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:
/*
<html>
<head>
<title>Film Search Result</title>
</head>
<body>
<h1>Film Search Results</h1>
<?php
trim($searchterm);
if (!$searchterm||!$searchtype)
{
echo "You have not entered search details. Please go back and try again.";
exit;
}
$searchtype=addslashes($searchtype);
$searchterm=addslashes($searchterm);
@ $db= mysql_connect("localhost");
if (!$db)
{
echo "Error: Could not connect to databases. Please try again later.";
exit;
}
mysql_select_db("test");
$query="SELECT* FROM film WHERE ". $searchtype. "like '%".$searchterm. "%'";
$result= mysql_query($query);
$num_results=mysql_num_rows($result);
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"]));
echo"</p>";
}
?>
</body>
</html>
*/
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.
Thanks!!