Welcome! Log In Create A New Profile


Search engine error 403

Posted by Johnny - 72985186 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Search engine error 403
May 10, 2011 10:34AM
For extra functionality I decided to add a search engine for the student_man and course_man pages so a user can search a specific student or course with keywords for when they pile up and get too many, though it probably would never be necessary for the course page as there wont be too many courses. But its just for extra functionality. However, I'm getting the following error: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
05/01/07 01:27:12
Apache/2.2.16 (Win32) PHP/5.3.3

Which seems odd because I am using the exact same includes/config.php to connect to my db than with all my other pages where I can del/add/edit or display db table results. Is there possibly a permission setting preventing the search from a search engine?

Here is my code:

Language: PHP
<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 //If form submitted $searching ='searching'; if ($searching =="yes") { echo "<h2>Results</h2><p>";   //Error if blank if ($find == "") { echo "<p>You forgot to enter a search term"; exit; }   //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>"; }   //Remind user what was searched for echo "<b>Searched For:</b> " .$find; } ?>

Is it possible that this is caused by this the form action: action="<?=$PHP_SELF?>">
Re: Search engine error 403
May 10, 2011 10:50AM
It says it is a server-related issue.... so search for a solution to the error "You don't have permission to access the requested object. It is either read-protected or not readable by the server."

Re: Search engine error 403
May 10, 2011 12:34PM
@Johnny, try replacing your $PHP_SELF with $_SERVER['PHP_SELF']
Re: Search engine error 403
May 10, 2011 01:08PM
Mmmm - yes, did not even see that - it is deprecated. I come from that era where it was used so I read it as is smiling smiley

Nonetheless, I would have expected it as a PHP Notice: Undefined variable: PHP_SELF . But that depends on your error settings, in which case it is in the apache error log. Remember to check it now and then.

This is what is killing in PHP - sometimes you sit for day and then the error is right in front of you. Which is why you need a second pair of eyes - here 3rd pair smiling smiley
Re: Search engine error 403
May 10, 2011 02:31PM
True, I gave up many scripts due to errors I couldn't find... Sometimes taking a break from the pc and getting back in touch with the real helps
avatar Re: Search engine error 403
May 11, 2011 12:12AM
Thanks Mac and Presub. Replaced "<?=$PHP_SELF?>"> with "<?=$_SERVER['PHP_SELF']?>" still received the error. Did some checking around, from what I found seems to be a configuration related problem. I don't know much about the config, permissions and sql etc. but I'm just confused as to why would this action have a permission error where as all my other actions which includes accessing and editing the database works fine. What makes this any different.

One recommendation I read was to turn short_open_tag = off to on in my php.ini. I don't know if this would be problematic but after doing so I no longer received the error. Also only worked with "<?=$_SERVER['PHP_SELF']?>" and not "<?=$PHP_SELF?>">. So yeah as far as I can tell the permission problem seems to be solved. Now to tend to a few errors in my code smile Thanks all
Sorry, only registered users may post in this forum.

Click here to login