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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dieselfuelonly
    New Member
    • Jun 2007
    • 2

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

    [code=php]<?php
    //Connect to the database and select the data from the table

    $username="asdf asdf";
    $password="asdf asdf";
    $database="asdf asdf";
    mysql_connect(l ocalhost,$usern ame,$password);
    @mysql_select_d b($database) or die("Unable to select database");
    $query="SELECT * FROM ut_players";
    $result=mysql_q uery($query);

    $num=mysql_numr ows($result);

    mysql_close();

    //Pull out the data
    $name=mysql_res ult($result,$i, "plr_name") ;
    $frags=mysql_re sult($result,$i ,"plr_frags" );
    $score=mysql_re sult($result,$i ,"plr_score" );
    $mlseconds=mysq l_result($resul t,$i,"plr_time" );
    $hours = floor($mlsecond s / 360000);

    //Generate the main static background

    $width = 400;
    $height = 50;

    $image = ImageCreate($wi dth, $height);
    $string = "test";
    $white = ImageColorAlloc ate($image, 255, 255, 255);
    $black = ImageColorAlloc ate($image, 0, 0, 0);

    ImageFill($imag e, 0, 0, $black);

    ImageFtText($im age, $pointsize, 0, 0, $white, $string);


    header("Content-Type: image/jpeg");

    ImageJpeg($imag e);

    ImageDestroy($i mage);
    ?>[/code]

    [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
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    You probably do not have Freetype 2 installed. I think you can check this with phpinfo().

    Comment

    • eragon
      Contributor
      • Mar 2007
      • 431

      #3
      dieselfuelonly, could you do us all th esimple favor of putting code in the code tags. it makes it really easy. ;)

      Comment

      • dieselfuelonly
        New Member
        • Jun 2007
        • 2

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

        [CODE=php]<?php
        //Connect to the database and select the data from the table

        $username="asdf asdf";
        $password="asdf asdf";
        $database="asdf asdf";
        mysql_connect(l ocalhost,$usern ame,$password);
        @mysql_select_d b($database) or die("Unable to select database");
        $query="SELECT * FROM ut_players";
        $result=mysql_q uery($query);

        $num=mysql_numr ows($result);

        mysql_close();

        //Pull out the data
        $name=mysql_res ult($result,$i, "plr_name") ;
        $frags=mysql_re sult($result,$i ,"plr_frags" );
        $score=mysql_re sult($result,$i ,"plr_score" );
        $mlseconds=mysq l_result($resul t,$i,"plr_time" );
        $hours = floor($mlsecond s / 360000);

        //Generate the main static background

        $width = 400;
        $height = 50;

        $image = ImageCreate($wi dth, $height);
        $string = "test";
        $white = ImageColorAlloc ate($image, 255, 255, 255);
        $black = ImageColorAlloc ate($image, 0, 0, 0);

        ImageFill($imag e, 0, 0, $black);

        ImageFtText($im age, $pointsize, 0, 0, $white, $string);


        header("Content-Type: image/jpeg");

        ImageJpeg($imag e);

        ImageDestroy($i mage);
        ?>[/CODE]
        Last edited by pbmods; Jun 14 '07, 07:10 PM. Reason: Changed code language. Thanks for using CODE tags!

        Comment

        Working...