The url: getdata.php?id=1 works just like a regular url on any php page, only difference with images the content type returned to the client/browser.
What php does is parse the URL sent to it via HTTP, in this case getdata.php?id=1.
If the HTTP method is "GET" as is the case, it will create a global variable $_GET.
$_GET is an associative array, with each parameter in the url set as an index, and the associated value as the value.
for getdata.php?id=1
[PHP]$_GET = array('id'=>'1'); // this is what PHP does automatically[/PHP]
so you can get the value with:
[PHP]$id = $_GET['id']; // will be equal to '1'[/PHP]
Older versions of PHP had a feature called "register globals" (I think). It automatically made every parameter passed in the URL a global.
Eg: for getdata.php?id=1
[PHP]$id; // will be equal to '1' in older php version, or when register globals is on[/PHP]
This isn't considered safe practice however, so may servers will disable it.
Something to note with generating images with php is that any output other than the binary data for the image will cause the image not to show.
So if you have a single error, everything messes up..
If you want to debug, find where you have the line:
[PHP]header("Content-Type: [/php]
and add a return or die(); right before it so you can debug. Otherwise your debugging will be interpreted by teh browser as part of the image data...
Last edited by digital-ether; Nov 13th, 2006 at 11:24 pm.
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
Offline 1,250 posts
since Sep 2005