473,569 Members | 2,984 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_re quest.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.ph p?$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 1596
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_re quest.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.ph p?$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.p hp?var1=".$var1 ."\">click here</a>";
?>
=============== =============== =====
<?php
// file2

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

--
Kim André Akerø
- ki******@NOSPAM betadome.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...whenev er 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
2584
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 : <? echo $var."\n"; echo $_GET."\n"; $var="gna"; echo $var."\n"; echo $_GET."\n"; $_GET="gnou";
7
11866
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 the top of my script I assign a few variables to incoming GET and POST values. $login = clean($_POST, 30); $passwd = clean($_POST, 30);
32
32991
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 the first time the page is loaded). I tryed this code:
7
14051
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, is_integer((int)$_GET). Then whatever I threw in the _GET variable passed as an integer, even strings. Any ideas or links or functions are much appreciated!
2
2658
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
8951
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> links to display the various tables. They all look something like: <a href=this_page.php?table=mytable1>the first table</a>
1
5667
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}'); </script>"; or maybe here, in file2 <?php $tk_req_id = $_GET;
2
3117
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, if not they are redirected to the login page. If logged in they may edit the story. I assign $_GET to $id.
17
1861
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, the URL shows the parameter. So far, so good. In foo.php there is no $_GET statement to decipher the value from bar. Furthermore, I did a grep...
0
7703
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...
0
8138
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...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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...
0
6290
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...
1
5514
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...
0
5228
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2118
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 we have to send another system
0
950
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...

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.