Tried both of those, and I have run the previous examples without a hitch (no problem when connecting to the db through the console.)
Is it possible that my PHP is not configured to handle MYSQL, or would that spit out an error message with the commands I put in?
Well in case it helps, here is the source of the results I get back from the server:
<html>
<head>
<title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
Works Here
Here is the php file with the new modifications you suggested:
<html>
<head>
<title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
<?
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try again.";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
echo "Works Here";
@ $db = mysql_pconnect('localhost', 'bookorama', 'password') or die('Failed to connect: ' . mysql_error());
echo "Now Working Here";
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
$query = "select * from books where ".$searchtype." like '%".$searchterm."%'";
mysql_select_db("books");
$result = mysql_query($query) or die('MySQL error: ' . mysql_error() . '<br>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 stripslashes($row["title"]);
echo "</strong><br>Author: ";
echo stripslashes($row["author"]);
echo "<br>ISBN: ";
echo stripslashes($row["isbn"]);
echo "<br>Price: ";
echo stripslashes($row["price"]);
echo "</p>";
}
?>
</body>
</html>
and here is the original search page:
<html>
<head>
<title>Book-O-Rama Catalog Search</title>
</head>
<body>
<h1>Book-O-Rama Catalog Search</h1>
<form action="results.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>