Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Bauer - helmikuu 28, 2014, 05:54:35 IP

Otsikko: Dynamic Signatures not Working
Kirjoitti: Bauer - helmikuu 28, 2014, 05:54:35 IP
Hi,
(Sorry for bad English).
I've made some dynmic sig script whitch is working when someon type his name then he shows the message with infos. Now it only shows picture wothout text. Here is the code:

$username="ussasamp_smf179"; //Your MySQL Username.
$password="blabla"; // Your MySQL Pass.
$database="ussasamp_smf179"; // Your MySQL database.
$host="localhost"; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.


$player_name=$_GET['member_name']; // This gets the player his name from the previous page.

/* Next, we will make a connection to the mysql.
If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */

mysql_connect($host,$username,$password); // Connection to the database.
@mysql_select_db($database) or die( "Nmg da se povezem na bazu. Niko nije savrsen."); //Selection of the database. If it can't read the database, it'll give an error.

/* To protect MySQL injection. */
$player_name = stripslashes($member_name);
$player_name = mysql_real_escape_string($member_name);



$query= mysql_query("SELECT real_name, posts, id_group, id_post_group, gender, avatar, usertitle, total_time_logged_in, profile_views, karma_bad, karma_good FROM smf_members WHERE member_name= '$player_name'");
$result=mysql_query($query);


/* We will now put the player's information into variables so we can use them more easily. */
/* DON'T FORGET: The names should be exact the same as in your mysql db.*/

    $Playername = $row['posts'];
    $Money = $row['real_name'];
    $Score = $row['karma_good'];
   
    // Creating of the .png image.
    header('Content-type: image/png');
    $im = @imagecreatefrompng('mypicture.png') or die("Cannot select the correct image. Please contact the webmaster."); // Don't forget to put your picture there.
    $text_color = imagecolorallocate($im, 197,197,199); // RED, GREEN, BLUE --> Go to www.colorpicker.com, select a nice color. Copy the R/G/B letters provided by colorpicker and put them here.
    $text_username = "$Playername"; // This gets the information about player name to be showed in the picture.
    $text_score = "$Score"; // Same as above ^^
    $text_money = "$Money"; // Same as above ^^
    $font = 'myfont.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here.
    /* USAGE OF THE imagettftext: First ($im) shouldn't be changed. (16) is the text-size. (0) is the angle of your text. Change it, and you'll see what's going on. (20) is de X-coordinate of the text.
    (36) is the Y-coordinate of the text. */
    imagettftext($im, 16, 0, 123, 33, $text_color, $font, $Playername); // Prints the username in the picture.
    imagettftext($im, 16, 0, 326, 37, $text_color, $font, $text_score); // Prints the score in the picture.
    imagettftext($im, 16, 0, 309, 102, $text_color, $font, $text_money); // Prints the money in the picture.
    imagepng($im);
    imagedestroy($im);

mysql_close();

?>


And that is what he shows for me: ussa-samp.com/signature.php?player_name=Bauer
Please help me and thank you :)