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

2006-04-29 Thread Richard Lynch
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



[PHP] GD text proc via php OK for local strings, but NOT for SESSION-passed strings. why?

2006-04-28 Thread OpenMacNews
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160


hi all,

php-5.1.2 built from src on OSX 10.4.6.

GD-2.0.33 + libpng-1.2.10 are built/enabled.

GD is working fine ... locally.

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?

thx!

richard

- --

/"\
\ /  ASCII Ribbon Campaign
 X   against HTML email, vCards
/ \  & micro$oft attachments

[GPG] OpenMacNews at gmail dot com
fingerprint: 50C9 1C46 2F8F DE42 2EDB  D460 95F7 DDBD 3671 08C6
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)

iEYEAREDAAYFAkRSjyEACgkQlffdvTZxCMZz/ACgvI60Zm6JfUDnczpOl3gpNLjj
ObMAoLOobf7h7CGuD6dX7Rz2KRV/9vsf
=Znuf
-END PGP SIGNATURE-

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