Re: GD text proc via php OK for local strings, but NOT for SESSION-passed strings. why?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, April 28, 2006 4:54 pm, OpenMacNews wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> in a given php file, this returns an image as expected:
>
> 	...
> 	$word="blah";
> 	imagefttext($im, ... other params ... , $word);
> 	...
> 	header ("Content-type: image/png");
> 	imagepng($im);
> 	...
>
> however, if rather than defining $word locally in the script, i
>
> 	$_SESSION['test']="blah";
>
> elsewhere, then:
>
> 	$word=$_SESSION['test']="blah";
> 	imagefttext($im, ... other params ... , $word);
> 	imagepng($im);
>
> i simply get a blank image.  NO error in either the browser or my
> apache
> logs.
>
> a simple test with:
>
> 	echo $word;
>
> outputs
>
> 	"blah"
>
> as expected; i.e, the _SESSION var *is* passed.
>
> QUESTION: what's different about the string passed via SESSION?

Just for fun, try it with imagestring.

And, really, show us the image creation and whatnot.

You've trimmed so much out, and we're going to have to second-guess
you and think you just messed up creating the image in the second
script, or that you got the arguments to the imagefttext() wrong,
which is easy to do, since there are so many paramters on those image
functions.

And the bits you've trimmed out wouldn't make your post THAT much
longer.  A handful of lines more, if you keep it to a minimum.

TIP:
I always copy and paste the prototype line from the reference manual
as a comment the line before my call to those image functions with
many arguments -- Then I can better track what I'm typing.

Yeah, those fancy IDEs can help too, but I'm an old-school vi kind of
guy -- The IDEs with all the bells and whistles just get in my way
more than they help.

It's pretty hard to see how the string coming from the SESSION could
matter...

Though there WAS one RC version where, as I recall, SESSION strings
were being passed out as, errr, references to strings, even though no
such beast actually exists in PHP User Land...

Altering the string would also alter the session data, which was very
disconcerting.

I don't see how that would apply here, mind you, but you could try this:

$word = '';
$word .= $_SESSION['test'];

The point being that by appending to an existing string, you can be
sure it's a "fresh" string, and not a reference to the string.

The bug I refer to was easily spotted by doing a var_dump on the data
string.  It showed "& string" rather than just "string", as I recall.
(Or maybe it was "string &")

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux