php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15052 Reserved Variable Name "id" ?
Submitted: 2002-01-15 11:56 UTC Modified: 2002-01-15 12:35 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rdv at teldo dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0CVS-2002-01-15 OS: WIn2k
Private report: No CVE-ID: None
 [2002-01-15 11:56 UTC] rdv at teldo dot de
Hi, I hope this is really a bug and I'm not too stupid:

In a larger script I used to embed variables in links, like this: search.php?a=1&b&c=2 witch worked perfectly.

But when I used "id" as Variablename it always got lost, so what should be "search.php&id=1" became "search.php&id=ressource id #1".

I looked for hours for the problem, than I renamed "id" to "it", and now the variables are transferred correctly and the program works.. 

So is id perhaps some kind of variable that is used by php internally ? I searched in the docus and the bug reports, but didn't find anything on it. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-15 11:58 UTC] rdv at teldo dot de
Hi, I hope this is really a bug and I'm not too stupid:

In a larger script I used to embed variables in links, like this:
search.php?a=1&b&c=2 which worked perfectly.

But when I used "id" as Variablename it always got lost, so what should
be "search.php&id=1" became "search.php&id=ressource id #1".

I looked for hours for the problem, than I renamed "id" to "it", and now
the variables are transferred correctly and the program works.. 

So is id perhaps some kind of variable that is used by php internally ?
I searched in the docus and the bug reports, but didn't find anything on
it. 

 [2002-01-15 12:16 UTC] imajes@php.net
$id is not a reserved variable, and should be useable where-ever you code.

You might find however that you have used id before in the script, so it is picking that variable, and you have a conflict.
 [2002-01-15 12:35 UTC] daniel@php.net
instead of:

  search.php&id=1

try:

  search.php?id=1

Kind Regards,
  Daniel Lorch
 [2003-07-14 15:34 UTC] mikea at gb-im dot com
We are having a similar problem with scripts that were working fine in older versions of PHP (4.16, etc.) and now that we are on version 4.3.1, any variable that I have that ends in the letters 'id' isn't being passed properly from POST submissions to form handler scripts. NO CODE HAS CHANGES IN THE SCRIPTS THEMSELVES, ONLY THE VERSION OF PHP HAS CHANGED.

For example:

A snipet from the form (I switched normal HTML brackets for square brackets for readibility and posible security issues on this bug tracker):

[form method="post" action="form_submit.php?ul=$ul&uid=$uid"]

COMMENT: the URL variables of UL and UID are pulled from values passed in on th calling link and represent user level and user ID respectively. I have no problem retrieving these values.

[select name="sid"]
[option value="NOTUSED"]NOTUSED[/option]
[option value=1]blah[/option]
[option value=2]rocco[/option]
[/select]

[/form]

COMMENT: When the form is submitted, I dynamically create an SQL string based on which form fields are filled out. So, in the receiving script, there is logic similar to this:

If ($sid != 'NOTUSED')
{

   $search_string = $search_string . " and sid = '$sid'";

}

When the script has finished looking at all of the submitted form values, and you look at the finished SQL query string, it ends up looking like this:

"select * from orders where stuff = 'stuff' and junk = 'junk' and sid = '1sid1'";

I honestly have no idea what is going on, a the scripts themselves worked fine under the older versions of PHP and now is doing this. It is a strange error. We temporarily fixed it by exploding the $sid variable. That allowed us to seperate out the first character and isolate it for use throughout the script.

Any thoughts?
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 24 11:01:24 2020 UTC