Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2.     header("Content-type: image/png");
  3.     $sql_handle = mysql_connect('localhost', 'phptest', 'alpine');
  4.     $IMG_base = imagecreatefrompng("bg.png");
  5.     $black = imagecolorallocate($IMG_base, 255, 255, 255);
  6.     $font = './tahoma.ttf';
  7.     if ($sql_handle)
  8.     {
  9.         //we are connected, resolve the stuff:
  10.         $db = mysql_select_db('dynSig', $sql_handle);
  11.         if (!$db) die(mysql_error());
  12.         $dbquery = "SELECT * FROM chatInfo ORDER BY TIME DESC LIMIT 5";
  13.         $result = mysql_query($dbquery, $sql_handle);
  14.         if (!$result) die(mysql_error());
  15.         $px = 13;
  16.         $py = 10;
  17.         for($i=0; $i<3; $i++)
  18.         {
  19.           $name = mysql_result($result, $i, 'name');
  20.           $text = mysql_result($result, $i, 'text');
  21.           $string = '<' . $name . '> ' . $text;
  22.           $py = $py + 15;
  23.           imagefttext($IMG_base, 10, 0, $px, $py, $black, $font, $string);  
  24.         }
  25.        
  26.         //image drawing stuff goes here
  27.         imagepng($IMG_base);
  28.         imagedestroy($IMG_base);
  29.      } else {
  30.         //handling routine goes here
  31.         echo "Cannae connect :()";
  32.     }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement