I am assuming you are trying to create a PNG from the username text taken from a mysql database. If so...
Assume the following:
MySql user is ProtoJazz
Password is secretpassword
Table name is users
Database is stored on the localhost
Database name is thedatabase
The mysql definition schema:
create table users {
id unsigned int auto_increment primary key,
username varchar(50) not null,
password varchar(10) not null
} type=myisam;
To retrieve the username from the database:
mysql_connect("localhost","ProtoJazz","secretpassword");
mysql_select_db("thedatabase");
$query = "SELECT * from users where username='" . $username . "'" . " and " . password='" . $password . "'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
header ("Content-type: image/png");
$row = mysql_fetch_array($result);
$text = $row['username'];
$im = imagecreatefrompng ("halo.png");
$white = imagecolorallocate ($im,255,255,255);
$blue = imagecolorallocate ($im,0,0,255);
$black = imagecolorallocate ($im,0,0,0);
imagestring ($im, 5, 0, 0, "$text", $blue);
imagepng($im);
}