Advertisement
Guest User

Untitled

a guest
May 30th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2. function LoadPNG($imgname)
  3. {
  4.     /* Attempt to open */
  5.     $im = @imagecreatefrompng($imgname);
  6.  
  7.     /* See if it failed */
  8.     if(!$im)
  9.     {
  10.         /* Create a blank image */
  11.         $im  = imagecreatetruecolor(150, 30);
  12.         $bgc = imagecolorallocate($im, 255, 255, 255);
  13.         $tc  = imagecolorallocate($im, 0, 0, 0);
  14.  
  15.         imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
  16.  
  17.         /* Output an error message */
  18.         imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
  19.     }
  20.  
  21.     return $im;
  22. }
  23.  
  24.  
  25. $username = "your_name";
  26. $password = "your_password";
  27. $hostname = "localhost";
  28.  
  29. //connection to the database
  30. $dbhandle = mysql_connect($hostname, $username, $password)
  31.   or die("Unable to connect to MySQL");
  32. echo "Connected to MySQL<br>";
  33.  
  34. //select a database to work with
  35. $selected = mysql_select_db("examples",$dbhandle)
  36.   or die("Could not select examples");
  37.  
  38. //haal getal uit database
  39. $number = '10';
  40.  
  41. //close the connection
  42. mysql_close($dbhandle);
  43.  
  44.  
  45.  
  46. $im = LoadPNG('test.png');
  47. $black = imagecolorallocate($im, 0, 0, 0);
  48. $text = "Kills: $number";
  49.  
  50. imagestring($im, 5, 5, 85, $text, $black);
  51.  
  52. header('Content-type: image/png');
  53. imagepng($im);
  54. imagedestroy($im);
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement