Image not showing when calling function

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
oilcanharry
Forum Newbie
Posts: 5
Joined: Mon Jan 12, 2009 8:39 am

Image not showing when calling function

Post by oilcanharry »

I have a verification image on my site that is not working. I get the 'red x' instead of the image. The person that wrote the code for this particular page sent me this message when I asked him about it.

I need to see the error when calling the function: ImageCreate(). It
appears that on your server, I cannot create a simple image using this php
function.

<?php header ("Content-type: image/png");
$handle = ImageCreate (130, 50) or die ("Cannot Create image");
$bg_color = ImageColorAllocate ($handle, 255, 0, 0);
ImagePng ($handle);
?>

You might need to refer to your hosting support to find out why. Once
that's resolve, I am sure the image verification image will appear.


I'm not a PHP person so does anyone know what might be happening and what I might do to solve the problem? If it's a server problem what can I do also? Thanks a lot.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Image not showing when calling function

Post by jaoudestudios »

Your server might not have the GD2 lib installed. This would cause the function to fail.

There are various options available to you, but depends on what you are trying to achieve? Is autogenerated image for a spam code?
oilcanharry
Forum Newbie
Posts: 5
Joined: Mon Jan 12, 2009 8:39 am

Re: Image not showing when calling function

Post by oilcanharry »

Your server might not have the GD2 lib installed. This would cause the function to fail.

My server is saying that GD v2.35 is installed.

There are various options available to you, but depends on what you are trying to achieve? Is autogenerated image for a spam code?

This website is a game site and the visitors have the option to signup for an account. That's the reason for the verification image, mainly to control the bots. Thanks for your response.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Image not showing when calling function

Post by jaoudestudios »

I know there is a new version of GD, not sure if it is v2 or GD2 or if they are the same.

You could use this instead, I have not used it, but other developers have and think it is great - easy to use and accessible.
http://recaptcha.net/captcha.html
oilcanharry
Forum Newbie
Posts: 5
Joined: Mon Jan 12, 2009 8:39 am

Re: Image not showing when calling function

Post by oilcanharry »

I appreciate your help. I was looking at the wrong information on my server and the GD Lib was not installed. I installed it and the image is showing up as it should now. Thanks a lot.
Post Reply