Search Query error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
selvaganesh87
Forum Newbie
Posts: 6
Joined: Wed Aug 25, 2010 8:18 pm

Search Query error

Post by selvaganesh87 »

Am learning PHP while learning i tried a concept to retrieve the data from server through PHP but i get some error i can't find it. I made a search box in HTML front end, and the back end PHP coding is made to retrieve the result from MYSQL server buy while searching from search box i get an 404 error not found. Any body here hep me to make it work
Here is my coding that i used

HTML CODING
<HTML>
<HEAD>
<TITLE>SERARCH ITEMS IN SHOP</TITLE>
</HEAD>
<BODY>
<FORM ACTION="DepartmentalStoreSearch.php" METHOD="POST">
<H3>Search for Your Product<H3><BR>
<input NAME="products" TYPE=TEXT>
<input TYPE=SUBMIT value="search">
</FORM>
</BODY>
</HTML>

PHP CODING

<HTML>
<HEAD>
<TITLE>FANCY PRODUCTS</TITLE>
</HEAD>
<BODY>
<?
$products = $_POST['products'];
$db = mysql_connect("localhost");
mysql_select_db("deptstore", $db);
$query = ("select storeproducts.PID, storeproducts.Pname, storeproducts.Tprice from storeproducts WHERE Pname LIKE '%$products%' ");
$result = mysql_query($query);
while($items = mysql_fetch_assoc($result)) {
while(list($sproductss, $spricess) = each($items)) {
echo $sproductss. ":" .$spricess. "<BR>";
}
}
?>
</BODY>
</HTML>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Search Query error

Post by requinix »

Did you name the PHP script DepartmentalStoreSearch.php? Are sure it doesn't have a .txt or .html extension?
selvaganesh87
Forum Newbie
Posts: 6
Joined: Wed Aug 25, 2010 8:18 pm

Re: Search Query error

Post by selvaganesh87 »

Thank u PHP guys i again renamed the php file with the name i given in HTML file, but i already given the same name but again i replaced out of luck and your guidance it is working. Thank you guys to spend your effort to make me understand
Post Reply