nomadsoul Posted October 17, 2009 Share Posted October 17, 2009 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. 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 try it on their server and tell me what happens: From: How to do everything with php and mysql, Vikram Vaswani. <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> Quote Link to comment https://forums.phpfreaks.com/topic/178004-single-quotes-causing-problems/ Share on other sites More sharing options...
gizmola Posted October 17, 2009 Share Posted October 17, 2009 If you're attempting to access the value of an array inside an interpolated string, and you want to specify the array index as a string literal, then you can do this using curly brackets. For example: echo "{anArray['something']}"; Also, on your short tag version, it's not being interpreted as being PHP. Try using <?php echo ... ?>. Quote Link to comment https://forums.phpfreaks.com/topic/178004-single-quotes-causing-problems/#findComment-938522 Share on other sites More sharing options...
nomadsoul Posted October 17, 2009 Author Share Posted October 17, 2009 Thanks Giz, I just tried this script on another webhost and it worked. I'm just wondering now why it's not working on my servers and why it is only the superglobals doing that. Am I not using <?php ? I thought I was. I guess I don't understand what you are saying, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/178004-single-quotes-causing-problems/#findComment-938539 Share on other sites More sharing options...
gizmola Posted October 17, 2009 Share Posted October 17, 2009 You had one example where you were using short tags ie. = rather than <?php as the start tag. This is a configurable item. Probably the host had it disabled. It's not a recommended setting to have on regardless. Otherwise, not my comment about putting arrays inside the {}, which will allow you to specify the single quotes around the array index name. Quote Link to comment https://forums.phpfreaks.com/topic/178004-single-quotes-causing-problems/#findComment-938842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.