You don't have permission to access

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bigalmeni
Forum Newbie
Posts: 3
Joined: Tue Oct 24, 2006 4:22 pm

You don't have permission to access

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
bigalmeni
Forum Newbie
Posts: 3
Joined: Tue Oct 24, 2006 4:22 pm

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but you are using them
bigalmeni wrote:<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
bigalmeni
Forum Newbie
Posts: 3
Joined: Tue Oct 24, 2006 4:22 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you're welcome
( This post is a shamless post count booster ;-) )
Post Reply