473,508 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_GET variable question

I have a file.php in which a created dynamic hypertext links and send a
variable $row[0]

echo "<td><a href='modify_request.php?$row[0]'>$row[0]</a></td>";

I can see in the url on modify_request.php the variable value.

But I can't get it in another variable in modify_request.php

here is a simple example of what I am trying to do with file1
============================

<?php
$var1 = 2;
echo "<a href='get_it.php?$var1'>click here</a>";
?>

and in file2 I try to use the variable $var2
==============================

<?php

$var2= $_GET[var1];

print "$var2";

?>

==============================
in that example, it doesn't print $var2...

can someone tell me what misses to make this work please?
Apr 3 '06 #1
3 1591
stephane wrote:
I have a file.php in which a created dynamic hypertext links and send
a variable $row[0]

echo "<td><a href='modify_request.php?$row[0]'>$row[0]</a></td>";

I can see in the url on modify_request.php the variable value.

But I can't get it in another variable in modify_request.php

here is a simple example of what I am trying to do with file1
============================

<?php
$var1 = 2;
echo "<a href='get_it.php?$var1'>click here</a>";
?>

and in file2 I try to use the variable $var2
==============================

<?php

$var2= $_GET[var1];

print "$var2";

?>

==============================
in that example, it doesn't print $var2...

can someone tell me what misses to make this work please?


Since you're not using a name=value combination, it isn't assigned to
any key in the $_GET array. What you rather need to do in the example,
is:

===================================
<?php
// file1

$var1 = 2;
echo "<a href=\"get_it.php?var1=".$var1."\">click here</a>";
?>
===================================
<?php
// file2

$var2 = $_GET["var1"];
echo $var2;
?>
===================================

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Apr 3 '06 #2
You also could get the whole string behind the "?" from
$_SERVER['QUERY_STRING']

Apr 3 '06 #3
a little tip that is not actually the problem here but it migth com in
handy in the future...whenever you use the $_GET into an if statement
remember to use the isset() function.
if (isset($_GET['var']))

is better then:
if ($_GET['var'])

they should both work but the second may sometime give you some
problems...

Apr 5 '06 #4

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

Similar topics

0
2572
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET...
7
11858
by: Dan | last post by:
I was trying to troubleshoot a login page that doesn't work - it keeps saying the login/password is missing - when my tracing discovered this peculiar behavior. register_globals is off, so at...
32
32962
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at...
7
14049
by: NotGiven | last post by:
I need to check the $_GET to make certain it is a positive integer. is_integer($_GET) is not working. I think it thinks it's a sting. So I tried casting it to an int using,...
2
2653
by: yawnmoth | last post by:
Say I have the following script - test.php: <? if (count($_GET) != 0) { foreach(array_keys($_GET) as $var) { echo "$var<br />"; } }
2
8944
by: Georg Weiler | last post by:
Hi, I'm biting my nails on this for several days now, hope that someone of you can help me...: On my page, the user can display tables, created out of a database. So I have several <a href>...
1
5661
by: stephane | last post by:
I have a problem which must be in this : print" <script type='text/javascript'> document.location.replace('http://127.0.0.1/add_task.php?req_id={$maxValue}&tk_request_name={$req_name}');...
2
3106
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
17
1854
by: sheldonlg | last post by:
I need to do some modifications on some code I just inherited and that code has me baffled. On one page, caller.php, with method get there is an anchor with href="foo.php?bar=123". On foo.php,...
0
7118
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
7379
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...
1
7038
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
7493
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...
0
5625
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,...
1
5049
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...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.