problem pulling the variable form a query string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tdock
Forum Newbie
Posts: 5
Joined: Mon Oct 23, 2006 7:48 am

problem pulling the variable form a query string

Post by tdock »

JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am having a problem pulling the variable from a query string

For example with this url: 

http://www.abc.com/go.php?id=2

I would like to pull the id value from the query string and use it for my $id variable within the go.php page. For simplification I tried this:

Code: Select all

<html>

<?php

$id = $_get['id'];

echo $id

</html>
I don’t understand why this doesn’t work. I would expect for the number 2 to display but I get nothing. I am new to php and any advice would be greatly appreciated.


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

<html>

<?php

$id = $_GET['id'];

echo $id;

</html>
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

You forgot to put ; after
echo $id
Maybe id it' s empty or the PHP parser doesn' t parse it (it' s an unknown index for it). Open your php.ini file and at the section \Error handling and logging enable to be displayed all (error_reporting = E_ALL)
tdock
Forum Newbie
Posts: 5
Joined: Mon Oct 23, 2006 7:48 am

Post by tdock »

Thanks!
Post Reply