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
icarpenter
Forum Commoner
Posts: 84 Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England
Post
by icarpenter » Tue Jul 05, 2005 9:46 am
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...
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
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Tue Jul 05, 2005 10:24 am
You could pass variables using GET:
Code: Select all
<img src = "e;createimage.php?id=12"e;>
then in createimage.php:
Code: Select all
<?PHP
$id = $_GETї'id'];
?>
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
icarpenter
Forum Commoner
Posts: 84 Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England
Post
by icarpenter » Fri Jul 08, 2005 5:38 am
Pickle you are a Legend!!!
It works better than Paracetamol no more headaches!!!
Thanks Ian
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Fri Jul 08, 2005 9:52 am
Glad to help.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
deep_fire
Forum Newbie
Posts: 7 Joined: Fri Jun 24, 2005 2:34 pm
Contact:
Post
by deep_fire » Sat Jul 09, 2005 5:16 pm
this is gcode.php
Code: Select all
<?
session_start();
$im = imagecreate(70, 23)
or die("e;Cannot Initialize new GD image stream"e;);
$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="e;gkod.php"e; align="e;absmiddle"e;>