Page 1 of 1

You don't have permission to access

Posted: Tue Oct 24, 2006 4:57 pm
by bigalmeni
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi All,

First some preliminaries.  I'm new to this forum.  I'm also WAMP newbie.  Please help me solve the problem described below?

I have installed Apache 2 &  PHP 5 on Windows XP Pro Sp2.  After I submit the form (the code fragment shown below which I copied from a book) I get the error message "[color=red]You don't have permission to access /< on this server[/color]".

When I checked the error log under Apache logs directory this is the error message in error.log file:

   "[color=red]The given path misformatted or contained invalid characters: Cannot map POST /%3C?=$_SERVER['PHP_SELF']?%3E HTTP/1.1 to file, referer: http://localhost/db2insert01.php[/color]"
   
   
   
Code Fragment:

Code: Select all

<html>
	<head>
	<basefont face="Arial">
	</head>
	<body>
	<?php
	if (!$_POST['submit'])
	{
	// form not submitted
	?>
		<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
			Item name: <input type="text" name="name">
			Item price: <input type="text" name="price">
			<input type="submit" name="submit">
		</form>
	<?php
	}
	else
	{
		// get form input
		// escape input values for greater safety
		$name = (trim($_POST['name']) == '') ? die ('ERROR: Enter a name') : mysql_escape_string($_POST['name']);
		$price = (trim($_POST['price'] == '') || !is_numeric($_POST['price'])) ? die ('ERROR: Enter a price') : $_POST['price'];

		// open connection
		// more code left out that is never reached
		...
		...
	}
	
	?>
	</body>
	</html>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Oct 24, 2006 5:32 pm
by volka
short tags are probably disabled on your system. If so

Code: Select all

neither
<? phpcode(); ?>
nor
<?=$var; ?>
will not work. Use

Code: Select all

<?php phpcode(); ?>
and
<?php echo $var; ?>
instead

Posted: Tue Oct 24, 2006 6:40 pm
by bigalmeni
Thanks feyd. I will study how to post correctly. Hopefully, I will post my next question or reply using the right format.

Thanks volka. But unless, I total misunderstand your suggestion, I'm not using the short tags as shown in my posted code. Any more ideas or suggestions, anyone?

Posted: Tue Oct 24, 2006 6:49 pm
by volka
but you are using them
bigalmeni wrote:<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

Posted: Wed Oct 25, 2006 2:11 am
by bigalmeni
Volka, you're absolutely right. I overlooked this part of the code. After replacing the short tag as you've suggested it works now. Thank you much for the solution and also for the link which provides valuable guidelines for newbies like myself.

Once again thanks.

Posted: Wed Oct 25, 2006 6:34 am
by volka
you're welcome
( This post is a shamless post count booster ;-) )