Johnnyboy123 Posted May 9, 2011 Share Posted May 9, 2011 I made a search engine to search my database for specific users ( well I used a tutorial ). I'm not getting any errors atleast when loading the page which is a first for me. However, now I am tackled by something new. When entering the keywords and submitting the search I get: Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. Error 403 127.0.0.1 04/30/07 11:09:21 Apache/2.2.16 (Win32) PHP/5.3.3 Which is odd for me because I am using the same config.php with connection code to connect to the db which I used with all my other pages. And in those pages I have been able to add/delete/edit and display records from the database tables. Does this have something to do with it being a search engine? Here is my code: <html> <head> </head> <body> <h2>Search</h2> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option> <Option VALUE="sname">Last Name</option> <Option VALUE="sno">Profile</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> </body> </html> <?php //This is only displayed if they have submitted the form $searching ='searching'; if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter data then they receive an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise connect to database include 'includes/config.php'; include 'includes/functions.php'; connect(); // filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); // search for term in specified field $data = mysql_query("SELECT * FROM student WHERE upper($field) LIKE'%$find%'"); // display results while($result = mysql_fetch_array( $data )) { echo $result['fname']; echo " "; echo $result['sname']; echo "<br>"; echo $result['sno']; echo "<br>"; echo "<br>"; } //Counts number or results and display message if there we're non $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> Any ideas? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/ Share on other sites More sharing options...
wildteen88 Posted May 9, 2011 Share Posted May 9, 2011 If you are submitting the form to itself then leave the action attribute empty <form name="search" method="post" action="<?=$PHP_SELF?>"> Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1212968 Share on other sites More sharing options...
Johnnyboy123 Posted May 9, 2011 Author Share Posted May 9, 2011 When leaving the action attribute empty the form does nothing when being submitted. Also for what it's worth tried copying the php section and saving it as a different file called search2.php and then using action="search2.php". But still only the form and nothing happens when submitting. Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1213063 Share on other sites More sharing options...
Johnnyboy123 Posted May 10, 2011 Author Share Posted May 10, 2011 Tried fixing the error 403. Someone had a similar problem and in his php.ini file (im using easyphp) he turned "short_open_tags" on. Fixed his problem. I did the same, however, now I'm stuck with a new error: Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1213268 Share on other sites More sharing options...
Tonic-_- Posted May 10, 2011 Share Posted May 10, 2011 To me this sounds like a permissions problem or a misconfiguration in PHP. If you are running this on a linux box try chmodding the file to 0750 (750 via FTP) Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1213271 Share on other sites More sharing options...
Johnnyboy123 Posted May 10, 2011 Author Share Posted May 10, 2011 Yeah but I dont understand I dont have any problems with any of my other pages which interacts with my db and tables. Any idea how to set the permissions or configuration so it will cope with this? not running linux. Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1213354 Share on other sites More sharing options...
Johnnyboy123 Posted May 10, 2011 Author Share Posted May 10, 2011 I'm using easyphp 5.3.3 Quote Link to comment https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/#findComment-1213357 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.