Easy Question

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
mevasquez
Forum Newbie
Posts: 1
Joined: Tue Apr 06, 2004 5:42 pm
Contact:

Easy Question

Post by mevasquez »

I have been out of php for about four years. Boy, how we can forget, but anyway, in my new job I was asked to create a php page which will view a pdf file. This I can do; however, I am having a problem passing the variable data. The link will have the following

...viewpdf.asp?id=6625

when I tried to view the output of $id, I get nothing.

Code: Select all

<?
echo "id=$id"
?>
I get nothing from $id.

I know this is simple but what am I doing wrong?

TIA
Mike
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your code assumes two (bad) things: short open tags is on, register globals is on.

<?php is the proper, and only future proof way to start php. $_GET['id'] is the proper way to access the url variable.

isset(), array_key_exists() among others should be of interest too.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

And you may want to change the file extension from .asp to .php :wink:
Post Reply