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.
localhost
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 :

<?php
$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!";
}
?>
<html>
<head>
<title> A PHP number guessing script</title>
</head>
<body>
<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>
</form>
</body>
</html>

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

try to check all directory permission, set to rw

How can I do that? I am using windows..

Are you running the 64bit WampServer package?

If so, can you access http://localhost ?

I am using XAMPP and I can access localhost

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.