Problems(I think)with superglobals and single quotes.

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
nomadsoul
Forum Newbie
Posts: 3
Joined: Sat Oct 17, 2009 2:24 am

Problems(I think)with superglobals and single quotes.

Post by nomadsoul »

Apache 2.2
Fedora 5
Php 5
notepad++
register globals: off

Hi all,
TIA.
I'm not really sure how to ask this question but bear with me while I try to explain.
In my superglobals such as $name_$POST['name'];
'name' is grayed out (i'm using notepad++) and my script does not work, I get a blank browser window on submit. But when I take out the sq's: $name_$POST[name]; name is boldened but I get an Access forbidden! after submit
as in:
You don't have permission blah blah blah. Even with full Chmod 777.
On submit my Url also reads: http://localhost/howto/%3C?=$_SERVER[%27PHP_SELF%27]?%3E

All of my scripts with superglobals are affected. But regular variables and anything else with sq's are unnaffected

here is one of the scripts I'm using. It is a unified form and process script. I hope someone has time to try it on their server and tell me what happens:
From: How to do everything with php and mysql, Vikram Vaswani.

Code: Select all

 
<html>
<head></head>
<body>
<?php
// if the "submit" variable does not exist
// form has not been submitted
// display initial page
 
if (!$_POST['submit'])
{
?>
<form action="<?=$_SERVER[PHP_SELF]?>" method="post">
Enter a number: <input name="number" size="2">
<input type="submit" name="submit" value="Go">
</form>
<?php
}
else
{
// if the "submit" variable exists
// the form has been submitted
// look for and process form data
// display result
$number = $_POST['number'];
if ($number > 0)
{
echo 'You entered a positive number';
}
elseif ($number < 0)
{
echo 'You entered a negative number';
}
else
{
echo 'You entered 0';
}
}
?>
</body>
</html>
 
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Problems(I think)with superglobals and single quotes.

Post by jackpf »

Do you have short tags turned on?
nomadsoul
Forum Newbie
Posts: 3
Joined: Sat Oct 17, 2009 2:24 am

Re: Problems(I think)with superglobals and single quotes.

Post by nomadsoul »

I didn't think about that. I will check. Thanks.
I tried the script on a commercial server and it works fine.
So maybe it is that.
nomadsoul
Forum Newbie
Posts: 3
Joined: Sat Oct 17, 2009 2:24 am

Re: Problems(I think)with superglobals and single quotes.

Post by nomadsoul »

phpinfo says:
short_open_tag Off Off

I'm quite befuddled about this.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Problems(I think)with superglobals and single quotes.

Post by jackpf »

Well, either turn it on or don't use short tags ;)
Post Reply