peterw555 Posted January 28, 2007 Share Posted January 28, 2007 Ive got this PHP script searching my SQL database and it references itself to display results etc, but when I hit submit IE errors that it cannot find the page specified... Below is the script, any help would be very appreciated...<h2>Search</h2> <form name="search" method="post" action="<?=$PHP_SELF?>">Seach for: <input type="text" name="find" /> in <Select NAME="field"><Option VALUE="serialnumb">Serial Number</option><Option VALUE="namemach">Name</option><Option VALUE="makemach">Make</option></Select><input type="hidden" name="searching" value="yes" /><input type="submit" name="search" value="Search" /><? //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("seewhats") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM database WHERE ($field) LIKE'%$find%'"); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['serialnumb']; echo " "; echo $result['namemach']; echo "<br>"; echo $result['makemach']; echo "<br>"; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } echo "<b>Searched For:</b> " .$find; } ?></form> Link to comment https://forums.phpfreaks.com/topic/36061-search-script-on-site/ Share on other sites More sharing options...
JasonLewis Posted January 28, 2007 Share Posted January 28, 2007 this: [code=php:0]<?=$PHP_SELF?>[/code] should be [code=php:0]<?=$_SERVER['PHP_SELF']?>[/code]don't think that will fix your problem. so it SAYS that the actual page cannot be found? Link to comment https://forums.phpfreaks.com/topic/36061-search-script-on-site/#findComment-171474 Share on other sites More sharing options...
peterw555 Posted January 29, 2007 Author Share Posted January 29, 2007 I tried with the SERVER tag and still no luck, when i run the the script it displays a "Page cannot be displayed" page, with the address of http:\\mysite\< Link to comment https://forums.phpfreaks.com/topic/36061-search-script-on-site/#findComment-171693 Share on other sites More sharing options...
JasonLewis Posted January 29, 2007 Share Posted January 29, 2007 instead of using the $_SERVER['PHP_SELF'] try putting the actual page name in there. like testpage.php Link to comment https://forums.phpfreaks.com/topic/36061-search-script-on-site/#findComment-172257 Share on other sites More sharing options...
peterw555 Posted January 30, 2007 Author Share Posted January 30, 2007 No luck, it just refreshes the page and takes away the search criteria... I was thinking of splitting the 1 doc into an HTML form and a sperate PHP script, is this more likely to work ?? Link to comment https://forums.phpfreaks.com/topic/36061-search-script-on-site/#findComment-172626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.