helraizer 1 Light Poster

Hey folks, yet again.

if ($back == "m") //$back is a value pulled from a db; that works perfectly.
    {
        $wid = $rowing['width'];
        $hei = $rowing['height'];
        createthumb("660x240background2.gif", "./user/" . $user . "_back.gif", $wid, $hei);

        $image = imagecreatefromgif("./user/" . $user . "_back.gif");
        $blue = ImageColorAllocate($image, 200, 200, 255); // prepare some blueness
        $black = ImageColorAllocate($image, 0, 0, 0); // ... and whiteness
        $im = ImageCreate(300, 35);
        $black_a = imagecolorallocate($im, 0, 0, 0);
        $white_a = imagecolortransparent($im, $black_a);
        $white = ImageColorAllocate($im, 255, 255, 255);
        ImageFill($im, 0, 0, $white_a);
        Imagettftext($im, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");

        $cur_line_y = 65; // This stores how far down the image the current line will print

        $postperpage = 11;
       }
elseif ($back == "u")
    {
        $wid = $rowing['width'];
        $hei = $rowing['height'];



        //        createthumb("./user/".$user."_img.gif", "./user/" . $user . "_backim.gif", $wid, $hei);

        imagecreatefromgif("./user/" . $user . "_img.gif");



        $images = imagecreate($wid, $hei);

        $imge = imagecreatefromgif("./user/" . $user . "_backim.gif");

        imagecopymerge($images, $imge, 0, 0, 0, 0, $wid, $hei, 20);

        imagegif($images, "./user/" . $user . "_back_trans.gif");

        $image = imagecreatefromgif("./user/" . $user . "_back_trans.gif");

$im = ImageCreate(300, 35);
        $black_a = imagecolorallocate($im, 0, 0, 0);
        $white_a = imagecolortransparent($im, $black_a);
        $white = ImageColorAllocate($im, 255, 255, 255);
        ImageFill($im, 0, 0, $white_a);
        Imagettftext($im, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");
        
        $cur_line_y = 74; // This stores how far down the image the current line will print
        $postperpage = 10;
    }

$sql = ""; // no need for actuall SQL statement - it works.

$result = mysql_query($sql) or die("error in  sqllls: " . mysql_error());


$cur_line_x = 24; // This stores how far across the image the current line will print
$pagecharwidth = 75; // this is the maximum length of the line before it wraps;
$lineheight = 18; // This is how much to move down to print the next line
$pagelinelimit = 1; // How many of each comment appears per page.


//ImageString($image, 3, 15, $cur_line_y, trim(stripslashes($wordwrapped[0])), $black);

$numberOfLines = $pagelinelimit;

for ($i = 0; $i < $numberOfLines; $i++)
{
    while ($row = mysql_fetch_array($result))
    {

        $name = "[" . htmlspecialchars_decode($row['username']) . "] "; //it works - returns username
        $font = $row['font']; //it works - renders the colour
        $color = $row['color']; //it works - changes the font
        $line = htmlspecialchars_decode($row['comment']); //it works, posts the shout

 if ($name == "[] ")
        {
            $name = "";

            $line = $name . $line;
        }
        else
        {
            $line = $name . $line;

        }

//code for emoticons.

//add shouts to image!
        if ($back == "m" )
        {
            if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
                "orange" || $color == "aqua")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }
            elseif ($color != "white" || $color != "yellow" || $color != "green" || $color !=
                "orange" || $color != "aqua")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
                    trim($line));


            }
            elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
                "timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }
            else
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf", trim
                    ($line));


            }

        }
        elseif ($back == "w" )
        {

            $blac = imagecolorallocate($image, 0, 0, 0);

            if ($color == "black" || $color == "purple" || $color == "blue" || $color ==
                "emerald" || $color == "red")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }
            elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
                "emerald" || $color != "red")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $blac, getfont($font),
                    trim($line));


            }
            elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
                "timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }
            else
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf", trim
                    ($line));


            }

           }

Depending on the values of $back, the background of the image changes and the font colours also change. This code works so far.

Problem code

elseif($back == "u")
           {
			   if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
                "orange" || $color == "aqua")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
                "emerald" || $color != "red")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
                    trim($line));


            }
            elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
                "timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
            {
                Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, getColor($color), getfont
                    ($font), trim($line));


            }
           else
           {
               Imagettftext($image, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf", trim
                 ($line) . "    ");


           }
		}
    
        $cur_line_y += $lineheight;


    }
}

The problem is that when $back == "u", for the first two comments the colours are normal then after that the older comments turn black; the newest comment is in colour but it also changes the colour of the $im that says "User's Shoutbox", which is created as a seperate image.

I can't, for the life of me, see the problem.. can you?

An example: $back == "u" because it's an uploaded background. The oldest comment was white, then I added the Yellow comment, the white one turned black.

[img]http://www.helraizer.co.uk/mychatbox/user/lucifer.gif[/img]

Hope that makes sense; if you need more code, just ask. =)
Sam