Hello I am trying a code from a book, When I run it at local host and enter a number on the box I get this error :

Have requested is not allowed to access the directory. Directory, or to read protected, or can not be read by the server.

If you think this is a server error, please contact the site administrator.
04.03.2011 11:43:22
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1

And this is the coed I am trying :

$num_to_guess = 42;
if (!isset($_POST['guess'])) {
	 $message = "Welcome to the guessing machine!";
} else if ($_POST['guess'] > $num_to_guess) {
	$message = "$_POST[guess] is too big! Try a smaller number.";
} else if ($_POST[guess] < $num_to_guess) {
	$message = "$_POST[guess] is too small! Try a larger number.";
} else { // must be equivalent
	$message = "Well done!";
<title> A PHP number guessing script</title>
<h1><?php echo $message; ?></h1>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
<p><strong>Type your guess here:</strong> <input type="text" name="guess"></p>
<p><input type="submit" value="submit your guess"></p>

Can you tell me why I am getting an error. Thanks

Edited by newbiecoder: n/a

6 Years
Discussion Span
Last Post by happytogether

locate youre public_html or localhost dir/and youre file folder directory, just right click>properties and check the permission..
I have the same problem before and fixed it by changing directory permission
Sometimes the default permission is read-only.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.