473,422 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

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

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
3 1383
Motoma
3,237 Expert 2GB
You probably do not have Freetype 2 installed. I think you can check this with phpinfo().
Jun 13 '07 #2
eragon
431 256MB
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
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

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

Similar topics

4
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
2
by: David Elliott | last post by:
I am creating a control to display GIF/JPEG images for my website. The control has a Panel to hold the images. I would like to perform the following. 1) store the original on disk and create a...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
12
by: nephish | last post by:
Hello there, i am getting to need to make my web stuff more OO. i have a project at work that we are porting to the internet, and i started learning php to do so. the project is now mamoth is...
3
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i...
33
by: STILL LEARNING | last post by:
I'm not sure if this can even be done, but what prompts the question is my desire to be able to create an "Uber Link" script/code of some sort, such that even if the html page contains nothing but...
4
by: foss | last post by:
HI all, I am able to upload the image as blob to mysql. but while displaying the image i cant display it properly . The code used for uploading image to mysql inserts data into mysql table.The...
6
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
1
by: DarkGiank | last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.