imagecreate function problem

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
lemo
New php-forum User
New php-forum User
Posts: 25
Joined: Wed Mar 10, 2004 7:24 am

Wed May 12, 2004 7:26 am

hi,
I have a code that calls Imagecreate function in this line:

Code: Select all

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


but in the run page this error appears to me:
Fatal error: call to undefined function imagecreate in c:apache \htdocs\webvote\showpoll.php on line 77.

line 77 contain the line I have wrote above.
Can any one explain to me what is the problem ?? :help: :shock:
patience is the key for success...

lemo
New php-forum User
New php-forum User
Posts: 25
Joined: Wed Mar 10, 2004 7:24 am

Wed May 12, 2004 8:05 am

I forgat to say that I am using PHP4, and as I know, this function is included in this version.
patience is the key for success...

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Wed May 12, 2004 11:06 am

Write the function name in lowercase :)
Example:

Code: Select all

$im = imagecreate($width,$height);
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Wed May 12, 2004 12:12 pm

Function calls in PHP4 are case-insensitive. But it is good form to put them in lower-case. (Until PHP5, in which OO methods will have CamelCaps).

The problem is that you need to enable the GD extension in your copy of PHP. On windows, you can do this in php.ini. On other platforms you'll have to recompile. If you're in a shared hosting environment, contact your hosting provider.
Last edited by swirlee on Wed May 12, 2004 9:36 pm, edited 1 time in total.
Image

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Wed May 12, 2004 4:50 pm

I already did. What platform are you running on, for starters?
Image

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1279
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Wed May 12, 2004 7:59 pm

if you are running windows..
please find the "gd*.dll " uncomment it by removing... ";"

if you are running linux, sorry.. buddy, you've got to recompile...

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1279
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Sun May 16, 2004 7:43 pm

there is a comment something as

Code: Select all

extension=php_gd2.dll

uncomment that line

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Mon May 17, 2004 3:18 pm

The problem is that php's header() function is used to send raw HTTP headers, so header() must be sent before anything else, either by normal HTML tags, blank lines in a file, or from PHP.

Yeh i know, sometimes we can´t make it to be sent at first, so i usually use some javascript tricks for that!

Example:

Code: Select all

<?php

// The php tags here, are to run the javascript inside your php code!

?><head><script language="JavaScript1.1">location.replace("<? echo 'http://somewhere'; ?>");</script></head><?

?>
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
crazyfox
New php-forum User
New php-forum User
Posts: 17
Joined: Wed Jun 02, 2004 7:59 am

Wed Jun 02, 2004 8:34 am

Hmmm? I agree with Nona'a original post I have the same problem. I tried several things but none of them worked!!

I uncommented the extension section removing the ; symbol in my php.ini.

[1] Now it reads extension=php_gd.dll
[2] I checked my c:/php/extensions dir and there it is, the (php_gd.ll) file

Also on another subject my include_path reads
[1] include_path=".;c:\php\includes"

yet the browser seems to be taking ages to load (rather not to load) the desired page.

How can I activate the GD library or get phpo to load the php_gd.dll. Ther is another file in my c:/php/dll folder (gds32.dll). This all other files I have copied to my windows dir as well as my system and system32 folders and still I get the error of undefined function call to imagecreate.

I even edit my php script and renamed the call to the function from $im = imagecreate($width, $height) to $im = ImageCreate($width, $height) and still getting the undefined error. :?

Nona it seems we have the same text book! lol.


My platform is:
=-=-=-=-=-=-=
Windows 98 second endition
Apache 1.3
PHP 4
cRaZyFoX

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1279
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Thu Jun 03, 2004 7:32 pm

are you sure you 've restarted your webserver once you've changed the setting in php.ini file

User avatar
crazyfox
New php-forum User
New php-forum User
Posts: 17
Joined: Wed Jun 02, 2004 7:59 am

Sat Jun 05, 2004 2:00 am

ruturajv wrote:are you sure you 've restarted your webserver once you've changed the setting in php.ini file


Yes I shut down apache and MySQL each time and restart it but nothing! I even restarted my computer. Since my last post however, I had to resort to extreme measures. I backed up my httpd.conf and php.ini files before, when I first got php installed, so I just copied and pasted them from my A: drive and overwrite the old ones. :)

But although doing this restores my php back in working order I still cannot use imagecreate()! and my include_path reads:
include_path=c:\windows" - which works instead of include_path=".;c:\php\includes" which it should be but doesn't work...keeps the browser in a state of infinite loading with a blank screen. :(


I may just as well upgrade to the latest PHP4 stable version. :???:
cRaZyFoX

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Sat Jun 05, 2004 4:59 pm

Hey nona, what you´re saying i´ve already posted here (above) ;)
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
crazyfox
New php-forum User
New php-forum User
Posts: 17
Joined: Wed Jun 02, 2004 7:59 am

Sun Jun 06, 2004 3:33 am

gesf wrote:Hey nona, what you´re saying i´ve already posted here (above) ;)


You have some very good points in your link above. To answer the question you mentioned however in your above link
They even reference to you that by turning register_globals=off in the php.ini is the correct way. Why they did that I don't know.


Well in the php.ini file it reads
register_globals=On ;Whether or not to register the EGPCS variables as global variables. You may want to turn this off if you don't want to clutter your scripts' global scope with user data. This makes most sense when coupled with track_vars - in which case you can access all of the GPC variables through the $HTTP_*_VARS[], variables.You should do your best to write your scripts so that they do not require register_globals to be on; Using form variables as globals can easily lead to possible security problems, if the code is not very well thought of


So maybe that is why the said php book you referred to which it appears many of us in here owns a copy of, said it's not a good idea to turn the global function on. Still I got it enabled in my php.ini.

However you have opened my eyes to many other issues in your link that addresses many things.......GOOD :-D
cRaZyFoX

Post Reply