note 90760 added to function.imagepng

From: Date: Fri, 08 May 2009 11:17:00 +0000
Subject: note 90760 added to function.imagepng
Groups: php.notes 
Request: Send a blank email to php-notes+get-154350@lists.php.net to get a copy of this message
I ran across the following WRT sessions and image creation. In main.php: <?php (...session in progress...) $_SESSION['text']='some text...'; $imgSrc='http://foo.com/createImage.php?sid='.session_id(); echo('<img src="'.$imgSrc.'"/>'); unset($_SESSION['text']); ... ?> In createImage.php: <?php header('image/png'); session_id($_REQUEST['sid']); session_start(); $img=imagecreatetruecolor(200, 30); $text_color=imagecolorallocate($img, 200, 200, 200); imagestring($img, 5, 5, 5, $_SESSION['text'], $text_color); imagepng($img); imagedestroy($img); ?> Problem: main.php execution ends before createImage.php writing the text to image, thus the unset($_SESSION['text']) destroys the text and you end up with empty image. Solution: move call to unset() as last statement of createImage.php ---- Server IP: 85.196.44.41 Probable Submitter: 194.63.239.27 (proxied: 194.63.234.242) ---- Manual Page -- http://www.php.net/manual/en/function.imagepng.php Edit -- https://master.php.net/note/edit/90760 Del: integrated -- https://master.php.net/note/delete/90760/integrated Del: useless -- https://master.php.net/note/delete/90760/useless Del: bad code -- https://master.php.net/note/delete/90760/bad+code Del: spam -- https://master.php.net/note/delete/90760/spam Del: non-english -- https://master.php.net/note/delete/90760/non-english Del: in docs -- https://master.php.net/note/delete/90760/in+docs Del: other reasons-- https://master.php.net/note/delete/90760 Reject -- https://master.php.net/note/reject/90760 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154350) next »