/    Sign up×
Community /Pin to ProfileBookmark

$_GET variables from url

I’m having an issue that I can’t seem to resolve.

In test.php I have:

[code=php]<a href=”results.php?id=$id”>Click</a>[/code]

Then I click the link to results.php with the following code.

[code=php]
$var = $_GET[‘id’];
[/code]

However, $var is empty. Can someone tell me what I’m doing wrong?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 06.2010 — When you view the first file in the browser, what does the actual link look like when you do a "view source"? Perhaps $id does not have a value?
Copy linkTweet thisAlerts:
@quark76authorJun 06.2010 — Sorry about that. The first file has the variable set.

[code=php]
id = "1";

...

<a href="results.php?id=$id">Click</a>
[/code]
Copy linkTweet thisAlerts:
@NogDogJun 06.2010 — Is that a typo here, or did you forget the "$" at the start of the $id in the assignment statement? And what is the actual code being used to create the link? (I.e.: you need a PHP echo or print() statement to output the $id.)
×

Success!

Help @quark76 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...