Solved

Problem getting variables in URL

Posted on 2002-07-29
8
284 Views
Last Modified: 2008-03-06
index.php:

<? echo "test is: $test"; ?>

If I call the page via:
http://myhost/index.php?test=hey

Shouldn't it return:
test is: hey

All I get is:
test is:

Is something wrong with my installation? If so, what can I do to fix this?
0
Comment
Question by:polaughlin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 1

Expert Comment

by:Timelib
ID: 7186193
I've done the same code, but not in a echo command.

I usually put it into a variable, then echo or use it.

$TestVar = "Test is: $test";
echo $TestVar;

However, try to this to make sure you are passing URL GET variables.

echo "Test is:" . $test;

Should work, I use it all the time.
0
 

Author Comment

by:polaughlin
ID: 7186207
Does not work.
0
 

Author Comment

by:polaughlin
ID: 7186214
Does not work.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Accepted Solution

by:
Timelib earned 500 total points
ID: 7186312
Another test to try is the longer version of the code:

echo "Test is: " . $HTTP_GET_VARS["test"];

---

If that doesn't work, I'm not sure, but the follow section in your php.ini configures how your server reads it session, post, get, etc. variables.

This should be your default settings, make sure they are.

;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
;
; Note - track_vars is ALWAYS enabled as of PHP 4.0.3

; The separator used in PHP generated URLs to separate arguments.
; Default is "&".
;arg_separator.output = "&amp;"

; List of separator(s) used by PHP to parse input URLs into variables.
; Default is "&".
; NOTE: Every character in this directive is considered as separator!
;arg_separator.input = ";&"

; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC).  Registration is done from left to right, newer
; values override older values.
variables_order = "EGPCS"

; Whether or not to register the EGPCS variables as global variables.  You may
; want to turn this off if you don't want to clutter your scripts' global scope
; with user data.  This makes most sense when coupled with track_vars - in which
; case you can access all of the GPC variables through the $HTTP_*_VARS[],
; variables.
;
; You should do your best to write your scripts so that they do not require
; register_globals to be on;  Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
register_globals = On

; This directive tells PHP whether to declare the argv&argc variables (that
; would contain the GET information).  If you don't use these variables, you
; should turn it off for increased performance.
register_argc_argv = On

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

; This directive is deprecated.  Use variables_order instead.
gpc_order = "GPC"
0
 

Author Comment

by:polaughlin
ID: 7186353
Alright.  Register_globals in php.ini was set to Off.  

Changing it to On fixed the problem.  Is there something seriously wrong with changing this to On?

Thanks for your help.
0
 

Author Comment

by:polaughlin
ID: 7186469
I'd appreciate an answer to my last question.  Here's some more points.
0
 
LVL 1

Expert Comment

by:majorspank
ID: 7186660
The following link gives a decent opinion on why register_globals should be Off.

http://www.securiteam.com/securityreviews/6P00G2A3FG.html
0
 

Author Comment

by:polaughlin
ID: 7187022
Very informative.  I totally understand now.  Sorry I can't give you any points, majorspank.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question