Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-10-2004, 09:01 AM   PM User | #1
kusa
New Coder

 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
kusa is an unknown quantity at this point
Can you check the error inside?

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!!
kusa is offline   Reply With Quote
Old 10-10-2004, 11:46 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
What is the error you are receiving?
Fou-Lu is offline   Reply With Quote
Old 10-10-2004, 03:37 PM   PM User | #3
kusa
New Coder

 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
kusa is an unknown quantity at this point
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..
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"

"; } ?>
*/
Can you help me!!
kusa is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:36 AM.


Advertisement
Log in to turn off these ads.