Page 1 of 1

Image won't view with post

Posted: Sun Nov 01, 2009 7:31 am
by Gadgetmo
I've made an image with PHP that will work if you put text in:

Code: Select all

<?php
     header ("Content-type: image/png");
     $text = "text";
     $im = imagecreate (400, 30);
     $black = imagecolorallocate ($im, 0, 0, 0);
     $white = imagecolorallocate ($im, 255, 255, 255);
     imagettftext ($im, 20, 0, 10, 20, -$white, 
              "Arial.ttf", $text);
     imagepng ($im);
     imagedestroy ($im);
?>
(as shown on http://testphp.comlu.com/123.php), but if I do:

Code: Select all

<?php
     header ("Content-type: image/png");
     $text = $_POST("text");
     $im = imagecreate (400, 30);
     $black = imagecolorallocate ($im, 0, 0, 0);
     $white = imagecolorallocate ($im, 255, 255, 255);
     imagettftext ($im, 20, 0, 10, 20, -$white, 
              "Arial.ttf", $text);
     imagepng ($im);
     imagedestroy ($im);
?>
,
it won't work and just shows blank (an example is on http://testphp.comlu.com/testform.php).
Please help!

Thanks,
Arthur

Re: Image won't view with post

Posted: Sun Nov 01, 2009 12:48 pm
by jackpf
Try commenting out the header() function. I think you're getting an error/warning, but you can't see it because of the content type.

Re: Image won't view with post

Posted: Sun Nov 01, 2009 6:06 pm
by McInfo
$_POST is an array, not a function.

Code: Select all

$_POST("text")
should be

Code: Select all

$_POST["text"]
Why is $white negated on line 7?

Edit: This post was recovered from search engine cache.

Re: Image won't view with post

Posted: Tue Nov 03, 2009 10:04 am
by Gadgetmo
McInfo wrote: Why is $white negated on line 7?
I'm gonna use it later on.

Thanks,
Arthur

Re: Image won't view with post

Posted: Sun Nov 08, 2009 7:59 am
by Gadgetmo
Why is $white negated on line 7?
Oh right, that. I dunno. 8O