Ok here is the lengthy code:
//This is my search form in my Home.html file:
<form action="search.php" method="post">
<input type="text" name="searchstring" cols="10">
<input type="submit" value="GO" />
</form>
//This is the search.php file:
<?php
include ("startmarket.php");
include ("header.php");
if($searchstring == "")
{
print "Please hit the back button and enter a keyword in the search field.";
exit;
}
$sql="SELECT * FROM products WHERE name LIKE '%$searchstring%' ";
$search_result = mysql_query ($sql) or die('Error executing sql: '.$sql.'<br />MySQL Reported:'.mysql_error());
while ($row = mysql_fetch_array ($search_result))
{
echo "<a href=\"" . $row["url"] . "\"><img src=\"" . $row["imagefile"] . "\" border=0 alt=\"" . $row["name"] . "\"></a><BR>";
echo "<b>" . $row["name"] . "</b><br>";
echo $row["description"] . "<br>";
echo "<b>Price: $</b>";
echo "<b>" . $row["price"] . "</b><br><hr /><br>";
}
include ("footer.php");
?>
//The startmarket.php file just includes DB access:
<?
// Connect to the database
mysql_connect ('localhost', '', '') ;
mysql_select_db ('mymarket');
?>
The header.php file was taken from the home.html file. So the code is the same. I've included attachments of the files in this post. At first I thought maybe my startmarket.php was the problem. But I do have php pages that do not access the DB. As I stated in my previous post, I only need to go to a php page for the search to start working. I then thought maybe my home.html and header.php had different code in them. But they don't. I've tried going back to the home.html after opening a php page, and my search works. I hope I've explained this good enough, I'm still very new at this. Any help would be great, thanks.
Jeremy