Page 1 of 1

imagecreatefrompng() headaches?

Posted: Tue Jul 05, 2005 9:46 am
by icarpenter
Hi

I am trying to pass a value into a function that creates an image using imagecreatefrompng()

but I keep getting headers already sent errors...

I can display the image if I move the script out of a function and into another document and reference this using...

Code: Select all

<img src="createimage.php"  />
However I cant seem to pass any values into this and I am reluctant to use $_SESSION variables for this...

Does anyone have any ideas on how this could be implemented?

Rgds Ian

Posted: Tue Jul 05, 2005 10:24 am
by pickle
You could pass variables using GET:

Code: Select all

&lt;img src = &quote;createimage.php?id=12&quote;&gt;
then in createimage.php:

Code: Select all

&lt;?PHP
$id = $_GET&#1111;'id'];
?&gt;

Posted: Fri Jul 08, 2005 5:38 am
by icarpenter
Pickle you are a Legend!!!

It works better than Paracetamol no more headaches!!!

Thanks Ian

Posted: Fri Jul 08, 2005 9:52 am
by pickle
Glad to help.

I use this

Posted: Sat Jul 09, 2005 5:16 pm
by deep_fire
this is gcode.php

Code: Select all

<?
session_start();
$im = imagecreate(70, 23)
   or die(&quote;Cannot Initialize new GD image stream&quote;);
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0,0 , 0);
imagestring($im, 5, 6, 6,  $random_num, $text_color);
imagegif($im);
imagedestroy($im);
?>
and I call gcode.php like this

Code: Select all

<?
/* security code */
$maxran = 1000000;
$random_num = mt_rand(0, $maxran);
session_register('random_num');
/* security code end */
 ?>
 <img src=&quote;gkod.php&quote; align=&quote;absmiddle&quote;>