By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

help passing variables

P: 67
test.php:

<?php
$d=$_GET['data'];
echo $d;
?>

when i go to
www....com/test.php?data=1
nothing happens.

I have read a few articles on passing variables through the url and i believe this is the right syntax. Anyone see something im doing wrong?

Thanks
Apr 27 '07 #1
Share this Question
Share on Google+
5 Replies


code green
Expert 100+
P: 1,726
Syntax look OK. 'Nothing happens' is not much help. Do you go to the page you expect
Apr 28 '07 #2

100+
P: 136
Hi,

it should show 1 in the page. If u like to do something else u need to write the code instead of writting echo $d;
test.php:

<?php
$d=$_GET['data'];
echo $d;
?>

when i go to
www....com/test.php?data=1
nothing happens.

I have read a few articles on passing variables through the url and i believe this is the right syntax. Anyone see something im doing wrong?

Thanks
susen
Apr 28 '07 #3

P: 67
thats the problem, it does not show 1

if i change the code to:
$d = $_GET['data'];
echo ("hi" . $d); and go to www...com/test.php?$data=1; it prints:

Hi

However if i change
$d = $_GET['data'];
to
$d = 1;

Then it will print
Hi 1, like expected
Apr 28 '07 #4

code green
Expert 100+
P: 1,726
Your posted code is inconsistent! Your first post named the url variable data
Expand|Select|Wrap|Line Numbers
  1. data.www....com/test.php?data=1 
In the second you name it $data
Expand|Select|Wrap|Line Numbers
  1. www...com/test.php?$data=1;
The dollar should not be there
Apr 30 '07 #5

100+
P: 136
Hi,

the url should be www....com/test.php?data=1 not the 2nd one. Try $_REQUEST['data']. But I still don't found any problem with ur code.

susen
Apr 30 '07 #6

Post your reply

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