Hi,
I passed rnd int parameter via session and later wanted to generate picture (circles) - amount based on that session parameter. Did not worked. PLS help. Thanks.
Session:
session_register("sc");
session_register("se");
if (empty($_SESSION["sc"])) {
$_SESSION['sc']= rand(1,5);
$_SESSION['se']= rand(1,5);
}
PICTURE:
$size = 300;
$image=imagecreatetruecolor($xscale,$yscale);
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $xscale - 1, $yscale - 1, $back);
imagerectangle($image, 0, 0, $xscale - 1, $yscale - 1, $border);
$xc=$_SESSION['sc'];
for ( $counter = 1; $counter<=$xc; $counter += 1) {
$xp=rand($mincirc, $xscale-$mincirc);
$yp=rand($mincirc, $yscale-$mincirc);
$xs=rand($mincirc, $maxcirc);
$v11=rand(0, 255);
$v12=rand(0, 255);
$v13=rand(0, 255);
$yel = imagecolorallocatealpha($image, $v11, $v12, $v13, 75);
imagefilledellipse($image, $xp, $yp, $xs, $xs, $yel);
}
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
return $image;
num parameters passed via session
Moderator: General Moderators
Re: num parameters passed via session
General Posting Guidelines
1. Post code in tags.
2. Give detailed explanations of what you're trying to do and what problems you're having.
3. We don't fix your problems - we tell you what you can try.
You remember to session_start() on both pages?
1. Post code in
Code: Select all
2. Give detailed explanations of what you're trying to do and what problems you're having.
3. We don't fix your problems - we tell you what you can try.
You remember to session_start() on both pages?
Re: num parameters passed via session
OK,
So, session is started each time on index.php, as first step.
Than later on there is a picture generated by php file, the source of the picture generator is shown in PICTURE section.
If I include similar script like :
for(...){
echo $counter.
}
I can see numbers generated by script. That part is ok.
But:
1. if I use same steps to generate circles, it does not work
2. if I replace session parameter with exact number (3 or 4), it works.
So I can see, that the problem is somewhere between passing the value from session into loop.
But I am not able to solve this.
So, session is started each time on index.php, as first step.
Than later on there is a picture generated by php file, the source of the picture generator is shown in PICTURE section.
If I include similar script like :
for(...){
echo $counter.
}
I can see numbers generated by script. That part is ok.
But:
1. if I use same steps to generate circles, it does not work
2. if I replace session parameter with exact number (3 or 4), it works.
So I can see, that the problem is somewhere between passing the value from session into loop.
But I am not able to solve this.