homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Resizing image problem won't work after turning registers globals

 9:47 am on Jun 1, 2009 (gmt 0)

Hi after I turned off the registers_globals for my server, my mini image resizing program no longer works. Do you guys know why? Is there a quick fix to this?

Header("Content-type: image/jpeg");
$filenamee = "$_SERVER[DOCUMENT_ROOT]/$filename";
$orig_image = imagecreatefromjpeg($filenamee);
list($width, $height, $type, $attr) = getimagesize($filenamee);
if ($width > $size) {
$ratio = $size / $width;
$newwidth = $size;
$newheight = $ratio * $height; }
if ($width <= $size) {
$newwidth = $width;
$newheight = $height; }
$sm_image = imagecreatetruecolor($newwidth,$newheight) or die ("Cannot Initialize new GD image stream");;



 11:44 am on Jun 1, 2009 (gmt 0)

Register globals would put any global variable, such as the name part of the name/value pair of a QUERY_STRING, into the global scope automatically. In the following url,

both $name and $size would be defined and ready for use in the PHP script with their values already assigned. This created security nightmares as you can imagine.

Your $size field looks to be undefined in your script and therefore failing. You need to define it by assigning it the appropriate value.


 4:46 pm on Jun 1, 2009 (gmt 0)

Thanks for the reply. Though I'm not too sure what you mean.

I use this URL before and the program has successfully re-sized the image.

Thanks again.

[edited by: dreamcatcher at 6:04 pm (utc) on June 1, 2009]
[edit reason] use example.com. Thanks. [/edit]


 6:06 pm on Jun 1, 2009 (gmt 0)

What coopster means is that the variables are only available in the global scope automatically with register globals ON. If you have them off you need to access them directly in the superglobal array $_GET.

$size = $_GET['size'];
$filename = $_GET['filename'];


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved