422,577 Members | 823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,577 IT Pros & Developers. It's quick & easy.

Need a little help with creating an image from MySQL data...

P: 2
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //Connect to the database and select the data from the table
  3.  
  4. $username="asdfasdf";
  5. $password="asdfasdf";
  6. $database="asdfasdf";
  7. mysql_connect(localhost,$username,$password);
  8. @mysql_select_db($database) or die("Unable to select database");
  9. $query="SELECT * FROM  ut_players";
  10. $result=mysql_query($query);
  11.  
  12. $num=mysql_numrows($result);
  13.  
  14. mysql_close();
  15.  
  16. //Pull out the data
  17. $name=mysql_result($result,$i,"plr_name");
  18. $frags=mysql_result($result,$i,"plr_frags");
  19. $score=mysql_result($result,$i,"plr_score");
  20. $mlseconds=mysql_result($result,$i,"plr_time");
  21. $hours = floor($mlseconds / 360000);
  22.  
  23. //Generate the main static background
  24.  
  25. $width = 400;
  26. $height = 50; 
  27.  
  28. $image = ImageCreate($width, $height);  
  29. $string = "test";
  30. $white = ImageColorAllocate($image, 255, 255, 255);
  31. $black = ImageColorAllocate($image, 0, 0, 0);
  32.  
  33. ImageFill($image, 0, 0, $black); 
  34.  
  35. ImageFtText($image, $pointsize, 0, 0, $white, $string);
  36.  
  37.  
  38. header("Content-Type: image/jpeg"); 
  39.  
  40. ImageJpeg($image);
  41.  
  42. ImageDestroy($image);
  43. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]

Here is the error I get when I get to the web page:
Call to undefined function: imagefttext

I know the script may seem a little random, but all I was trying to get it to do was print the string "test" on to the image so that when viewed in the browser someone would see the word test on the image. Any help?

Thanks much,

Dennis
Jun 13 '07 #1
Share this Question
Share on Google+
3 Replies


Motoma
Expert 2.5K+
P: 3,235
You probably do not have Freetype 2 installed. I think you can check this with phpinfo().
Jun 13 '07 #2

eragon
100+
P: 431
dieselfuelonly, could you do us all th esimple favor of putting code in the code tags. it makes it really easy. ;)
Jun 14 '07 #3

P: 2
As far as I know it is installed... Sorry, here it is in the code tags:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //Connect to the database and select the data from the table
  3.  
  4. $username="asdfasdf";
  5. $password="asdfasdf";
  6. $database="asdfasdf";
  7. mysql_connect(localhost,$username,$password);
  8. @mysql_select_db($database) or die("Unable to select database");
  9. $query="SELECT * FROM ut_players";
  10. $result=mysql_query($query);
  11.  
  12. $num=mysql_numrows($result);
  13.  
  14. mysql_close();
  15.  
  16. //Pull out the data
  17. $name=mysql_result($result,$i,"plr_name");
  18. $frags=mysql_result($result,$i,"plr_frags");
  19. $score=mysql_result($result,$i,"plr_score");
  20. $mlseconds=mysql_result($result,$i,"plr_time");
  21. $hours = floor($mlseconds / 360000);
  22.  
  23. //Generate the main static background
  24.  
  25. $width = 400;
  26. $height = 50;
  27.  
  28. $image = ImageCreate($width, $height);
  29. $string = "test";
  30. $white = ImageColorAllocate($image, 255, 255, 255);
  31. $black = ImageColorAllocate($image, 0, 0, 0);
  32.  
  33. ImageFill($image, 0, 0, $black);
  34.  
  35. ImageFtText($image, $pointsize, 0, 0, $white, $string);
  36.  
  37.  
  38. header("Content-Type: image/jpeg");
  39.  
  40. ImageJpeg($image);
  41.  
  42. ImageDestroy($image);
  43. ?>
Jun 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.