Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/178004-single-quotes-causing-problems/
Share on other sites

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 ... ?>.

 

 

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.