This code is correct. What's not working for you?
As I understand you want to use some background and write on it?
PHP Code:
$img_handle = @ImageCreateFromPNG("playersonline.png");
if(!$img_handle) {
// error to create background (no image?) use your code for this part.
} else {
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 235, 235, 51);
$myFile = "online.txt";
$fh = fopen($myFile, 'r');
$theData = fgets($fh);
fclose($fh);
ImageString ($img_handle, 10, 5, 5, "$theData", $txt_color);
ImagePng ($img_handle);
}
just change 10, 5 to values which will set your number in proper place of image.