473,772 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Odd variable Bug

I am using PHP 4.3.4 and found something strange with a variable name.
When I try to use "$company" variable (lowercase), I get odd behavior
from that variable. The name of my php file is "company.ph p" but I
didn't think that php associated them together. The behavior is that
"$company" will take on values of the previously accessed $_GET
variable. I fixed it by using "$company_i nfo" variable instead but I
would really like to know why the "$company" variable seems to be a
landmine.

The code includes the core Pear libraries and the pear IT library but
nothing else. I thought that system variables took the form of
"$_VAR"?

If anyone has run into odd behavior like this before let me know so I
can
find out what variables to avoid in the future.

Sam
Jul 17 '05 #1
4 1687
On 30 Jul 2004 17:18:41 -0700, gl********@adel phia.net (Lost arcade)
wrote:
I am using PHP 4.3.4 and found something strange with a variable name.
When I try to use "$company" variable (lowercase), I get odd behavior
from that variable. The name of my php file is "company.ph p" but I
didn't think that php associated them together. The behavior is that
"$company" will take on values of the previously accessed $_GET
variable. I fixed it by using "$company_i nfo" variable instead but I
would really like to know why the "$company" variable seems to be a
landmine.

The code includes the core Pear libraries and the pear IT library but
nothing else. I thought that system variables took the form of
"$_VAR"?

If anyone has run into odd behavior like this before let me know so I
can
find out what variables to avoid in the future.


Any $_GET("varname" > will override $varname, no?

--
gburnore@databa six dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
=============== =============== =============== =============== ===============
Want one? GET one! http://signup.databasix.com
=============== =============== =============== =============== ===============
Jul 17 '05 #2
"Lost arcade" wrote:
I am using PHP 4.3.4 and found something strange with a variable name. When I try to use "$company" variable (lowercase), I get odd behavior from that variable. The name of my php file is "company.ph p" but I didn’t think that php associated them together. The behavior is
that
"$company" will take on values of the previously accessed $_GET
variable. I fixed it by using "$company_i nfo" variable instead but I would really like to know why the "$company" variable seems to be a landmine.

The code includes the core Pear libraries and the pear IT library but nothing else. I thought that system variables took the form of
"$_VAR"?

If anyone has run into odd behavior like this before let me know so I can
find out what variables to avoid in the future.

Sam


Sam, that behavior is due to register_globas being ON. This is not a
good thing. You would want register globals off. It "should" be
OFF by default in your version of php.
http://www.desilva.biz/apache/regblsoff.html

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Odd-vari...ict135185.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=451438
Jul 17 '05 #3
On 30 Jul 2004 21:58:49 -0400, steve <Us************ @dbForumz.com>
wrote:
"Lost arcade" wrote:
I am using PHP 4.3.4 and found something strange with a variable

name.
When I try to use "$company" variable (lowercase), I get odd

behavior
from that variable. The name of my php file is "company.ph p" but

I
didn’t think that php associated them together. The behavior is
that
"$company" will take on values of the previously accessed $_GET
variable. I fixed it by using "$company_i nfo" variable instead

but I
would really like to know why the "$company" variable seems to be

a
landmine.

The code includes the core Pear libraries and the pear IT library

but
nothing else. I thought that system variables took the form of
"$_VAR"?

If anyone has run into odd behavior like this before let me know so

I
can
find out what variables to avoid in the future.

Sam


Sam, that behavior is due to register_globas being ON. This is not a
good thing. You would want register globals off. It "should" be
OFF by default in your version of php.
http://www.desilva.biz/apache/regblsoff.html


Heh. WAAAAY back in a previous version somewhere, it must have been on
by default? I've not used the same variable name as a $_GET or $_POST
variable because I thought I had to. Not that it hurts to use
slightly different names.

(I usually use:

$VariableName = $_POST['variable_name'];

)


--
gburnore@databa six dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
=============== =============== =============== =============== ===============
Want one? GET one! http://signup.databasix.com
=============== =============== =============== =============== ===============
Jul 17 '05 #4
"Gary L. Burnore" wrote:
On 30 Jul 2004 21:58:49 -0400, steve
<Us************ @dbForumz.com>
wrote:
"Lost arcade" wrote:
I am using PHP 4.3.4 and found something strange with a variable
name.
When I try to use "$company" variable (lowercase), I get oddbehavior
from that variable. The name of my php file is "company.ph p" but
I
didn’t think that php associated them together. The

behavior is that
"$company" will take on values of the previously accessed $_GET variable. I fixed it by using "$company_i nfo" variable instead
but I
would really like to know why the "$company" variable seems

to be
a
landmine.

The code includes the core Pear libraries and the pear IT

library
but
nothing else. I thought that system variables took the form

of "$_VAR"?

If anyone has run into odd behavior like this before let me

know so
I
can
find out what variables to avoid in the future.

Sam


Sam, that behavior is due to register_globas being ON. This is

not a
good thing. You would want register globals off. It "should"

beOFF by default in your version of php.
http://www.desilva.biz/apache/regblsoff.html


Heh. WAAAAY back in a previous version somewhere, it must have been

on by default? I’ve not used the same variable name as a $_GET or
$_POST
variable because I thought I had to. Not that it hurts to use
slightly different names.

(I usually use:

$VariableName = $_POST[’variable_name’];

)


register_globas is a left-over from older versions of php. When you
posted a variable, it would be available both as $_POST[’xyz’] and
$xyz. That was a BAD thing, since someone could insert some POST or
GET variables and they would show up as regular variables.

So as you state, one should always use $_POST or $_GET to access such
variables, and if at all possible (except due to old code) turn off
register_global s.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Odd-vari...ict135185.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=451493
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4561
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable name="Tim">ZXCVBNM</Variable> <Function id="1"> <Parameter type="String">Bob</Parameter> <Parameter type="String">Steve</Parameter>
4
3246
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable name="Banner_error_2"> errormessage 2 for banner </xsl:variable>
134
7914
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
10
2256
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal multiplyer as integer, ByVal variable as ___?) variable = 5 * multiplyer end function What I would like this function to do is take the name of the incoming variable and assign a calculated value to it. Any help would be greatly appreciated, TIA!!
23
19203
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
3963
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable name="fileName">../../data/models/<xsl:value-of select="."/>.xml</xsl:variable> I want to use this variable as an argument of the document function: <xsl:apply-templates mode="coordinates" select="document( REFERENCE
1
25699
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
2
3684
by: Florian Loitsch | last post by:
hi, What should be the output of the following code-snippet? === var x = "global"; function f() { var x = 0; eval("function x() { return false; }"); delete x; alert(x); }
37
5480
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods are the one which runs statically with the defining class. Hence, my understanding is that static variables must be bound to the class defining the variables and shared by children of parent class where the variable is defined. But, please have a...
112
5478
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.