Need help on query error!
Posted: Mon Mar 12, 2007 4:07 pm
Everah | Please use
and the php script that is called on submit is result.php that is bellow:[/syntax]
I'm using dreamweaver 8 with xampp v1.5.5 and the fact is that the php code is having a error that i can't find 2 weeks now.I don't anderstand.every thing is working apart from this one.
I need serious help.
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello! guys ,i'm new in php and using a SAMS "php and MySql web development" ebook and i'm on the stage in which we retreive info from the database through html search page which is below:
[syntax="html"]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Book-o-Rama Catalogue search</title>
</head>
<body>
<h1>Book-o-Rama Catalogue search</h1>
<form action="result.php" method="post">
Choose search Type:<br />
<select name="searchtype">
<option value="author">Author
<option value="title">Title
<option value="isbn">ISBN
</select>
<br />
Enter search Term:<br />
<input name="searchterm" type="text" />
<br />
<input type="submit" value="search" />
</form>
</body>
</html>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Book-o-Rama search results</title>
</head>
<body>
<h1>Book-o-Rama search results</h1>
<?php
$searchtype = $_POST["searchtype"];
$searchterm = $_POST["searchterm"];
trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo "you have not entered searchdetails.Please go back and try again.";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
$db = mysql_pconnect("localhost","root","mamamia");
if (! $db)
{
echo "Error: could not connect to the Database.Please try again later.";
exit;
}
mysql_select_db("books");
$query = "select*from books where".$searchtype."like'%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p> Number of books 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>Author : ";
echo htmlspecialchars(stripslashes($row["author"]));
echo "<br>ISBN: ";
echo htmlspecialchars(stripslashes($row["isbn"]));
echo "<br>Price : ";
echo htmlspecialchars(stripslashes($row["price"]));
echo "</p>" ;
}
?>
</body>
</html>I need serious help.
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]