define a function

I’m trying to install the MyPHPauction script and can’t get past this error in the login.php

Fatal error: Call to undefined function ImageFontWidth() in /home/laparker250/public_html/auction/includes/functions.php on line 28

the relevant file - functions.php -

function show_pin_image ($full_pin, $generated_pin, $image_url = ‘’)
{
## create an image not a text for the pin
$font = 6;
$width = ImageFontWidth($font) * strlen($generated_pin); <----line 28
$height = ImageFontHeight($font);

I know just about zip about php and the company I bought the script from, while great in responding, can’t help much. They said the script was written for PHP 5.3 but will work in 5.4. I’m running 5.4.26 on a Godaddy VPS - Apache 2.2.26

Thanks,
Lee

It looks like the script (Framework) isn’t being included, for example:

[php]include “Name_of_the_MyPHPPauction.php”;[/php]

I might be wrong, but that is where I would start in the debugging process.

That script ( Name_of_the_MyPHPPauction.php ) or anything similar isn’t in the program.

Thanks,
Lee

OK, maybe if I reword what I am trying to say it will make myself clear?

this ImageFontWidth($font) is a function and there has to be a script to go along with it. The script that you bought is probably (not probably is) in a separate external file. It needs to be included with the page that you are writing, otherwise you will be getting undefined function every time.

Or if you pasted the code in then you risk the chance of introducing errors into the script (maybe that is what you’re doing), besides this would make the script not very portable.

Well, another possible issue is that you typed this in and did not realize that PHP is very very
capital-sensitive. There is a PHP command for imagefontwidth, but, it does NOT have any caps in it.

Here is the description of this command for you to review:
http://php.net/manual/en/function.imagefontwidth.php

Hope that is the problem… Just a spelling issue…

I changed that and the next line for font height to lower case, tried to log in and got the same error for the same line.

Lee

Well, did you read the link I gave you? It says you can use built-in fonts numbers 1 to 5, not 6 as you have
in our code. If you read the instructions, fonts over number 5 must be loaded first. so, I am guessing that
you are attempting to patch code together without understanding what is needed.

The instructions for that command says:

font
Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().</blockquote>

So, it can be 1 to 5. If you use #6, you must first pre-load the font with the imageloadfont() function.
(Unless you did this earlier in your code and are not showing it to us.)

For debugging it, try changing to built-in font #5 and see if it works.

Now, if you are using font #6 because you want a larger font, you will have to load that font and then get
the width after loading it. I would just try it with font#5… Good luck, let us know…

This script is totally one that I upload and use. I changed the font to 5 and got the same error with both ImageFontWidth and imagefontwidth. I just got an email from the place I got the script and they assured me nothing was missing. They have no problems when it is uploaded to HostGator and they have installed it on GoDaddy. They said that possibly GoDaddy has different configurations on different servers. I may have to have them install it.

Thanks,
Lee

Interesting… I have used that command in the past on my GoDaddy.com server without issues.
But, that was a long time ago. Perhaps there is some odd setting in your PHP files that are causing
it to fail. What are the values of the variables that you are putting into that error line?

Where you have:
$width = ImageFontWidth($font) * strlen($generated_pin);
place this for now and see what the outputs show you:
die(“font=” . $font . “
generated_pin=” . $generated_pin);
$width = ImageFontWidth($font) * strlen($generated_pin);

This will stop the processing and show you what you are using for data on line 28.
Since you are using a multiplication in that line, one of the two parts may not be numeric.
Also, you can add these lines at the beginning of the functions.php included file to show all errors
just in case details are being hidden:
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
This tells PHP to show all of the errors your code encounters not just the standard ones…

Let us know…

commented the // $Width line and inserted your code and added the error reporting code to the beginning of the file. -

Deprecated: Function eregi() is deprecated in /home/laparker250/public_html/auction/includes/global.php on line 92

Deprecated: Function eregi() is deprecated in /home/laparker250/public_html/auction/includes/global.php on line 98

Notice: Undefined index: myphpauction_is_seller in /home/laparker250/public_html/auction/includes/class_session.php on line 36

Notice: Undefined index: myphpauction_user_id in /home/laparker250/public_html/auction/includes/class_session.php on line 36
font=6
generated_pin=28b125ea

Thanks,
Lee

Well, the values of the variables are okay. the result would be 48.

The “Deprecated” command “eregi()” should be fixed at some time, but, is not the problem.

The Undefined index “myphpauction_is_seller” and “myphpauction_user_id” should be fixed
as these are most likely used in your code somewhere.

There is nothing that should not work.

I did some research for you and found this comment:
you don’t have the [php] GD extension loaded (and probably not even installed)

php.net/gd

mostly likely you’ll have to ask your sys admin to install/activate this
extension …

So, using Godaddy’s VPS server, the GD is not always installed by default. Godaddy’s site says it should be, but, others say it is not always there by default.

You should look at your PHP setup. To do this, put up a file on your server which has this line in it:

<?PHP phpinfo(); ?>

It should display all of your settings after PHP has been accessed. Look do that page and locate the notes
on the net-gd library and make sure it is activated. If it is not, you have to contact GoDaddy to set it up.
You might be able to find it in your control panel.

Not sure if that helps, but… Good luck.

I don’t believe GD is installed - phpinfo.txt attached - can’t get it to you any other way yet.

Thanks,

Lee


phpinfo.txt (44.9 KB)

I posted a reply, but, my computer was flaking out so not sure if you got it…

So, I looked around for you and found that is appears that on some servers you just check off this
extension library in their control panel to make it active. On others you have to execute a PHP line-command
that tells it to initialize the graphics library. On some systems, you have to log in using PUTTY or other
command-line secured connection to be able to tell PHP to start the GD library.

Here is a link that covers it for a lot of ways. If you read down the page, you should find the one that
will work for you. Otherwise, you will have to contact your hosting company and have them do it for you.
http://php.net/manual/en/image.installation.php

Hope this helps… Good luck. Let us know!

Sponsor our Newsletter | Privacy Policy | Terms of Service