undefined function error :( can anyone help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

undefined function error :( can anyone help

Post by mike08 »

i keep getting this error when trying to run my small online poll to create an image but doesn't seem to work - the error is:

Fatal error: Call to undefined function: imagecreate() in C:\Program Files\Apache Group\Apache2\htdocs\shopbots\show_poll.php on line 76


please can someone tell me what im doing wrong.

my code is below

Code: Select all

// create a blank canvas
$im = imagecreate($width,$height);   - error refers to this line 
     
// 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);
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

How you got the GD libray extension installed for PHP?

Also, please use BBCode to highlight your PHP...thanks

Mark
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

This is what i have in my php.ini folder

Post by mike08 »

i don't really know anything about the gb library. the code i got from a book but nothing says anything about installing a library. Do i have to then, if so where do i get it from?

Thanks for your help

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.


;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_crack.dll
;extension=php_curl.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zip.dll
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you need to remove the semi-colon from this line

;extension=php_gd2.dll

and restart apache or whatever webserver you are using

Mark
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

Another error now?

Post by mike08 »

Thanks mark

now it comes up with this error - sorry for bothering you.

any ideas now?

unknown(): Unable to load dynamic library './php_gd2.dll' - The specified module could not be found


cheers
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

your extension directory setting in php.ini is wrong. check it out
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

thanks

Post by mike08 »

is this what i need to change:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"

if so what should i change it to - im new to this sorry.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

do a file search for php_gd2.dll to see where it is

Usually somehwre like c:\php\extension (on windows)

Manual reference - http://uk.php.net/manual/en/ref.image.php

Mark
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

Thanks man your a god. Cheers

Post by mike08 »

:D
Post Reply