Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

imagecreate function problem

images php coding issues or problems here.

Moderators: macek, egami, gesf

imagecreate function problem

Postby lemo » 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:
lemo
New php-forum User
New php-forum User
 
Posts: 25
Joined: Wed Mar 10, 2004 7:24 am

Postby lemo » 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.
lemo
New php-forum User
New php-forum User
 
Posts: 25
Joined: Wed Mar 10, 2004 7:24 am

Postby gesf » Wed May 12, 2004 11:06 am

Write the function name in lowercase :)
Example:
Code: Select all
$im = imagecreate($width,$height);
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby swirlee » 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.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

hi

Postby nona » Wed May 12, 2004 1:47 pm

swirlee:

how can i enable the GD extension in PHP?
can u explane>>>plz :eek:
nona
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed May 12, 2004 12:03 pm
Location: ksa

Postby swirlee » Wed May 12, 2004 4:50 pm

I already did. What platform are you running on, for starters?
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

windows... linux..

Postby ruturajv » 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: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

HI

Postby nona » Fri May 14, 2004 4:32 am

MY PLATFORM IS WINDOWS,
AND WHEN I SEARCH >>> I FOUND MANY FILES
WHICH FILES IWILL REMOVE THE ";" .
THANX
nona
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed May 12, 2004 12:03 pm
Location: ksa

gd

Postby ruturajv » 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
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby nona » Mon May 17, 2004 3:09 pm

when i fixed this problem , appeare new one
the problem is:
function header
:eek:
warning: can not add header information - header already sent by (output started at .............

what is the problem wiyh it?????
nona
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed May 12, 2004 12:03 pm
Location: ksa

Postby gesf » 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><?

?>
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

call to undefined function imagecreate()

Postby crazyfox » 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
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby ruturajv » 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
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

imagecreate()

Postby crazyfox » 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. :???:
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am

Postby nona » Sat Jun 05, 2004 3:42 pm

hi every one
i ask some frinde and told me
" when i use the function header must not be above of it any echo or print any word , if u use make it in another file and inclde it "
try this ,

bay
nona
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed May 12, 2004 12:03 pm
Location: ksa

Postby gesf » Sat Jun 05, 2004 4:59 pm

Hey nona, what you´re saying i´ve already posted here (above) ;)
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby crazyfox » 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
User avatar
crazyfox
New php-forum User
New php-forum User
 
Posts: 19
Joined: Wed Jun 02, 2004 7:59 am


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.