473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Global variable turned on

160 100+
I have just moved to a new server and apparently I cannot use global variables as I used to. I would like to reenable this as it was in teh past.

I guess that there is a setting called global_variables that is set to "off" by default. How do I set this to "on"? I have root access on this server so there should be no problem with me being able to change this setting if I knew how.

actually my problem is that first i am able to use $username instead of $_POST['username'].
But on another server me not able to access like that
please tell me what changes i have to do


Thanks very much.
Jan 2 '09 #1
6 1988
Markus
6,050 Expert 4TB
You can edit your php configuration, if you have access to your php.ini file (config file).
Jan 2 '09 #2
Dormilich
8,658 Expert Mod 8TB
my advice: keep it like it is. register_globals was turned off because of security reasons (see PHP: Using Register Globals - Manual). and you're writing much cleaner code when using the apropriate superglobals ($_GET, $_POST, $_COOKIE, ...)

if you indeed need global data, you may consider using a class for that (e.g. the abstract registry pattern)

regards
Jan 2 '09 #3
waqasahmed996
160 100+
thanks for reply

i have to on global variable

i made changes in php.ini file as register_globals = On

and also in .htaccess file as php_flag register_globals on

but still global variable is off

please tell me whether this function is available for PHP version 5.2.5 or not????

because i am using PHP version 5.2.5

thanks
Jan 2 '09 #4
Dormilich
8,658 Expert Mod 8TB
did you restart the server? you need the changes loaded.

I still advice to use register_globals off.

and of PHP6 register_globals will be dropped.
Jan 2 '09 #5
Atli
5,058 Expert 4TB
You can turn register_globals on in all versions of PHP 5, but this is highly discouraged. It enables very bad coding habits and can potentially pose a huge security risk.

If you have no alternative but to turn it on, all you would have to do is change your php.ini to:
Expand|Select|Wrap|Line Numbers
  1. register_globals = on
And restart the server, of course.

If for some reason this is giving you trouble, and you absolutely have to have these variables in the global scope, you can use the extract function to simulate this behavior.
For example, this would print a field named "field1" submitted via the POST protocol:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. extract($_POST);
  3. echo $field1;
  4. ?>
Note that I DO NOT RECOMMEND THIS, but it is an option if you absolutely have no other choice.
Jan 2 '09 #6
waqasahmed996
160 100+
Thanx.You really give me good solutions
Thanks again
Jan 6 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steve Mauldin | last post by:
This is a standard ASP application that has several pages at the root withthe global.asa. I set a session variable session("accountid") = "123456" within an asp page and then response.redirect to...
10
by: Kleenex | last post by:
Reason: I am working on an embedded project which has very limited memory (under 512 bytes, 60 or so of which is stack space), which translates into limited stack space. In order to save on stack...
4
by: Alex Maghen | last post by:
This is weird On my WinXP development box, database calls made from within my GLOBAL.ASAX go to SQLServer as user "ASPNET" even though I have impersonation turned on in my web.config. That's fine...
37
by: eoindeb | last post by:
Sorry to ask another global variable question, but from reading other posts I'm still not sure whether to use them or not. I have a program with a set function that calls 4 other functions in...
9
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
0
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value),...
1
by: jobs | last post by:
I'm forcing an error/exception in one page as follows Protected Overrides Sub OnLoad(ByVal e As EventArgs) Dim badthing As New Exception("XXX") Throw badthing End Sub And attempting to set...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
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...
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.