473,396 Members | 2,011 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,396 software developers and data experts.

register_globals and $_SERVER['QUERY_STRING']

I use http variables with php - not sure if I've got the nomenclature
correct, so here's an example of what I'm talking about:

A navbar sends "somepage.php?somevariable" when the link is clicked. The
link looks like this:
<a href='somepage.php?somevariable'>Some Page</a>

Then I do stuff with "somevariable" in PHP code.

I understand that I need "register_globals = on" in my php.ini - but is
there any other config, Apache or otherwise, that needs to be set up?

I am not getting any value in $_SERVER['QUERY_STRING'];

Why no value? Other troubleshooting ideas?

Here's my server config:

L = rh9 2.4.20-8
A = apache 2.0.40-21
M = mysql-3.23.54
P = php4.2.2

Thanks in advance.
Jul 17 '05 #1
4 3735
.oO(deko)
A navbar sends "somepage.php?somevariable" when the link is clicked. The
link looks like this:
<a href='somepage.php?somevariable'>Some Page</a>

Then I do stuff with "somevariable" in PHP code.

I understand that I need "register_globals = on" in my php.ini
Why? It's off for good reasons. You may only need it for older or third-
party scripts, not for newly written ones.
- but is
there any other config, Apache or otherwise, that needs to be set up?

I am not getting any value in $_SERVER['QUERY_STRING'];

Why no value? Other troubleshooting ideas?


No idea at the moment, but if you need the posted variable - it's stored
in $_GET['somevariable'].

Micha
Jul 17 '05 #2
> No idea at the moment, but if you need the posted variable - it's stored
in $_GET['somevariable'].


Well, I'm not sure I understand. I don't know the value of 'somevariable' -
how do I retreive it"

Are you saying there is another way to get the value of a variable?
Currently I am using:

$nav = trim(strip_tags($_SERVER['QUERY_STRING']));

to retreive the value of variables passed thusly:

<a href='services.php?services'>Professional Services</a>

in this case, $nav = services

If there is a better way to retreive the value of the variable, I would like
to know. As for your suggestion with $_GET - can you give me an example?
Jul 17 '05 #3
.oO(deko)
No idea at the moment, but if you need the posted variable - it's stored
in $_GET['somevariable'].
Well, I'm not sure I understand. I don't know the value of 'somevariable' -


Ah, OK.
Are you saying there is another way to get the value of a variable?
Currently I am using:

$nav = trim(strip_tags($_SERVER['QUERY_STRING']));

to retreive the value of variables passed thusly:

<a href='services.php?services'>Professional Services</a>

in this case, $nav = services
Is it possible to change the link to something like

<a href='services.php?name=value'>?

Would make it much easier if you would know the name of the passed
parameter.
If there is a better way to retreive the value of the variable, I would like
to know. As for your suggestion with $_GET - can you give me an example?


URL-parameters are stored in the array $_GET, in the example above the
array would contain an empty element named 'somevariable':

Array
(
[somevariable] =>
)

You can use the key() function to get its name (assuming that there's
only one parameter passed to the page):

$nav = trim(strip_tags(key($_GET)));

See <http://www.php.net/key>. But again: It would be easier with a name,
especially if you want to pass more than one parameter:

<a href='services.php?foo=this;bar=that'>

Then the $_GET array would be

Array
(
[foo] => this
[bar] => that
)

HTH
Micha
Jul 17 '05 #4
> Is it possible to change the link to something like

<a href='services.php?name=value'>?


Yes. I tried it and it works fine. The only reason I was using
$_SERVER['QUERY_STRING']; was because of bad advice (that I paid $40/hour
for)... !

thanks for the help.
Jul 17 '05 #5

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

Similar topics

6
by: user | last post by:
when i first load index.php with arguments ie: "index.php?page=x", the $_SERVERvalue is null. I then get the session id appended to each link. If i refresh the page, I get the $_SERVER I want, but...
0
by: Simon | last post by:
Hi, When I have a page not found in Apache I can have it redirected to a custom ../error.php file and I can use $_SERVER to get the file that was not found. But as some of you might know, IIS...
3
by: Gilbert Saint-Flour | last post by:
Hello: I have this one line of PHP code which I'd like to convert to Javascript. The PHP code conditionally issues a BASE statement when the html page is called with a frame name, e.g....
25
by: wd | last post by:
I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404... But if they...
12
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if...
4
by: Jim Carlock | last post by:
Are the XSS / Cross Site Scripting attacks fixed in Version 4.44? I'm seeing that $_SERVER doesn't return the $_SERVER appended to it. I was just messing with a few things and noticed that...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
10
by: philleep | last post by:
Hi there, I have some PHP issues. Basically i've installed WAMP so that i can have a webserver/local host. I have a local host but at the moment the php isnt doing anything. Anywhere i use php...
5
by: Jim Carlock | last post by:
(1) test.php?test_key=test_value $_SERVER returns /test/test.php $_SERVER returns /test/test.php?test_key=test+value $_SERVER returns test_key=test+value (2)...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.