Forum Moderators: coopster

Message Too Old, No Replies

GD rejecting variables

         

Gero_Master

7:49 am on Apr 8, 2006 (gmt 0)

10+ Year Member



Hello!

I have a problem with GD image script.

GD only accepts colors formatted:
$borcol = 0x99;

but not:
$borcol = "0x99";

This makes the whole thing rather difficult as I can't fetch colors from database. The string dividing thing I requested before works fine, but GD doesn't accept the colors surrounded by quotes or colors fetched from database.

What should I do?

Birdman

10:55 am on Apr 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may need to force the variable to be evaluated as an integer. You can do this with type-casting:

$borcol = (int) "0x99";

or

$borcol = (int) $db_var;

Gero_Master

11:32 am on Apr 8, 2006 (gmt 0)

10+ Year Member



It didn't work. It still shows the color as black or atleast much darker.

Gero_Master

11:57 am on Apr 8, 2006 (gmt 0)

10+ Year Member



Sorry for double post, but I got it working. I just had to use a script which converts the HEX colour into RGB, which could then be used like this:

$borders = imagecolorallocate ($im,0x00+$bor1,0x00+$bor2,0x00+$bor3);