Advertisement
Guest User

Untitled

a guest
May 30th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 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 = "nawa";
  26. $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.  
  33. //select a database to work with
  34. $selected = mysql_select_db("nawa",$dbhandle)
  35. or die("Could not select database ".$database);
  36.  
  37. //haal getal uit database
  38. $sql = "SELECT nm, kills
  39.        FROM   killlist
  40.        WHERE  nm = ".mysql_real_escape_string($_REQUEST['nm']);
  41.  
  42. $result = mysql_query($sql);
  43.  
  44. if (!$result) {
  45.     die("Could not successfully run query ($sql) from DB: " . mysql_error());
  46. }
  47.  
  48. if (mysql_num_rows($result) == 0) {
  49.     die("No such nm found.");
  50. }
  51.  
  52. // Er hoort maar 1 row te zijn:
  53. if (mysql_num_rows($result) > 1) {
  54.     die("Error more then one row found.");
  55. }
  56.  
  57. $row = mysql_fetch_assoc($result);
  58.  
  59. $number = $row["kills"]
  60.  
  61. //close the connection
  62. mysql_close($dbhandle);
  63.  
  64.  
  65.  
  66. $im = LoadPNG('test.png');
  67. $black = imagecolorallocate($im, 0, 0, 0);
  68. $text = "Kills: $number";
  69.  
  70. imagestring($im, 5, 5, 85, $text, $black);
  71.  
  72. header('Content-type: image/png');
  73. imagepng($im);
  74. imagedestroy($im);
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement