can not call the undefined function iamgecreate()

Discussion in 'PHP' started by alanX, May 29, 2006.

  1. #1
    Hi:
    i am using Wamp1.6.3. When i call the function imagecreate(). it shows the error massage:
    Fatal error: Call to undefined function imagecreate() in C:\wamp\www\show_poll.php on line 77

    PHP script:( source from Textbook "PHP and MYSQL Web Development" chapter 19)

    ------------------------------------------------------------
    // create a blank canvas

    $im = imagecreate($width,$height);

    // Allocate colors
    $white=ImageColorAllocate($im,255,255,255);
    $blue=ImageColorAllocate($im,0,64,128);
    $black=ImageColorAllocate($im,0,0,0);
    $pink = ImageColorAllocate($im,255,78,243);

    $text_color = $black;
    $percent_color = $black;
    $bg_color = $white;
    $line_color = $black;
    $bar_color = $blue;
    $number_color = $pink;

    // Create "canvas" to draw on
    ImageFilledRectangle($im,0,0,$width,$height,$bg_color);

    // Draw outline around canvas
    ImageRectangle($im,0,0,$width-1,$height-1,$line_color);

    // Add title
    $title = 'Poll Results';
    $title_dimensions = ImageTTFBBox($title_size, 0, $font, $title);
    $title_length = $title_dimensions[2] - $title_dimensions[0];
    $title_height = abs($title_dimensions[7] - $title_dimensions[1]);
    $title_above_line = abs($title_dimensions[7]);
    $title_x = ($width-$title_length)/2; // center it in x
    $title_y = ($y - $title_height)/2 + $title_above_line; // center in y gap
    ImageTTFText($im, $title_size, 0, $title_x, $title_y,
    $text_color, $font, $title);

    // Draw a base line from a little above first bar location
    // to a little below last
    ImageLine($im, $x, $y-5, $x, $height-15, $line_color);

    /*******************************************
     
    alanX, May 29, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to make sure GD was installed. You can do so with the following code:

    
    <?php
    var_dump(gd_info());
    ?> 
    
    Code (markup):
    The problem is also discussed in a thread at the WAMP forum: Enabling GD in WAMP
     
    clancey, May 29, 2006 IP
  3. doneeh

    doneeh Active Member

    Messages:
    126
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    It should be no problem if you upload it
    Apache Win32 version is not bundled with GD, so you have to add it manual
     
    doneeh, May 29, 2006 IP
  4. alanX

    alanX Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi:
    I don't quite understand some points
    (1)WAMP system tray icon ------> where ?
    (2)PHP Extensions > Add Extension ... enter "php_gd2.dll" and hit return,
    ------------>where to complete the procedures.

    Thanks
     
    alanX, May 30, 2006 IP
  5. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I am sorry, but I cannot help you further. I do not use WAMP on my windows machines. I just installed everything by hand and edited the ini scripts as necessary. You need to review the forums at WAMP and the user documentation. It should contain the answers you need. For me to help you more, that is what I would be doing.

    The "system tray" is normally located at the bottom of the screen on a windows box on the right hand side of the bottom bar. You know, the one that appears at the bottom of the screen when you move the mouse to the bottom of the monitor. The right hand tray contains icons. Hover above those until you find the one with a message which appears to be from WAMP. However, if you told the install program not to include these extra desktop items, it will be missing.

    The php.ini file is normally located at your c:\windows\php.ini

    GD is found at: http://www.boutell.com/gd/
     
    clancey, May 30, 2006 IP