PHP imagettfext not displaying working

I used to use a script to change the text on an image via update form.

It worked perfectly at first while I was on a shared host with all modules pre-installed.

I moved to a vps where I had to install everything myself and now the script no longer works.

The php page is able to be displayed but when I update, the text does not show up like it used to.

Here is an example of the page on the shared host that still works: http://nyanpuffle.com/auntarctic/ Password is 1234

Here is an example of the page on the vps that does not work: http://www.clubpenguincheatsy.com/cptra … untarctic/">http://www.clubpenguincheatsy.com/cptrackers/auntarctic/ Password is 1234

Here is a copy of the coding used:

<title>Tracker</title>

 <center>
 Updated! ";
}else
{
echo "

**Incorrect Password!**

";
}
}
//This form remebers what they put, so they dont have to keep typing it in.
// $_SERVER['PHP_SELF'] Means Get this document to submit to.
// If you know html this will be familiar.
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

Password: 

Status: <select name="status"><option value="">Select...</option>
  <option value="Online"> Online</option>
  <option value="Offline"> Offline</option>
  <option value="Tracking..."> Tracking</option></select> 

Server: 

Room: 

</form>

Tracker:

![Tracker](out.png)

[Back to Tracker Dashbaord](http://ClubPenguincheatsy.com/cptrackers)
</center> 

The VPS is ran on Ubuntu and I have PHP,MYSQL, and Apache installed.

18 Replies

Make sure the GD and FreeType libraries are both installed. Most distributions have these in separate packages from the main PHP package. Be sure the font file you want to use is present.

Also, seems like the interpretation of the font file parameter has changed over time, so your script may need tweaking to account for this.

Everything is installed and enabled I believe.

Here is the new script:

<title>Tracker</title>

 <center>
 Updated! ";
    }else{
        $result="

**Incorrect Password!**

";
    }
}

echo (isset($result))?$result:'';
?>

<form action="" method="POST">

Password: 

Status: <select name="status"><option value="">Select...</option>
 Online\n";
echo " <option value="\&quot;Offline\&quot;&quot;;" if($status="='Offline'){" echo"="" selected="\&quot;selected\&quot;&quot;;}">Offline</option>\n";
echo " <option value="\&quot;Tracking...\&quot;&quot;;" if($status="='Tracking...'){" echo"="" selected="\&quot;selected\&quot;&quot;;}">Tracking</option>\n";
?></select> 

Server: 

Room: 

</form>

Tracker:

![Tracker](out.png)

[Back to Tracker Dashbaord](http://ClubPenguincheatsy.com/cptrackers)
</center> 

Page: http://www.clubpenguincheatsy.com/cptra … untarctic/">http://www.clubpenguincheatsy.com/cptrackers/auntarctic/

Pass is 1234

Text still doesn't update

Also, here is my PHP info:

http://www.clubpenguincheatsy.com/cptra … c/test.php">http://www.clubpenguincheatsy.com/cptrackers/auntarctic/test.php

When I load the script directly using:

clubpenguincheatsy.com/cptrackers/auntarctic/testing.php

The text updates.

But when I use the other script in my previous post using the update forms, nothing happens.

Check permissions in out.png. It's probably not writable by your webserver.

Well it wasn't writable, but setting the permissions to 777 didn't seem to help either.

EDIT:

Weird, after trying the permissions changes on another image. The text updated, but not the correct way. It removed the text that was already on the image but didn't replace it with the text I typed in the update form.

This is the latest reply I've gotten:

> Im very sorry but I cannot help, your code and my answerer is the very basic usage of GD, ive had alook at your phpinfo and at first glance it looks ok but can only see that your version of GD is 1.2.42 this maybe the problem as the latest version is 1.5.4 libpng.org/pub/png/libpng.html like other's have said make sure you permissions are correct. if your apache handlers are DSO mode change it too suPHP if you can so your script is not run as (nobody) but as your hosting username then chmod 0755 for folders & 0644 for files, apart from that I have no idea whats wrong. sorry

Any help on what he meant by this?

Make sure that the directory where out.png is writable by the user PHP runs as.

Yes I set the directory permissions to 777 to test it, nothing.

Would the fact that I had the same directory and images on my old server be a problem? All I did was move the databases and file directories when I moved my site.

Could there be some type of cached DB query that would cause the image not to update?

Try changing ownership of the directory(s) and file like you did in your other thread.

Yeah just tried that. Didn't seem to work either. I'm starting to think I'm gonna need a new script.

It's just weird, because it works when I render the image directly.

Just won't let me update it with the forms.

That to me, still points to a permissions issue. You are logged in as root. There is nothing to stop you from doing anything. PHP/Apache is running as www-data. That user doesn't have access to everything on the system. Make sure that the www-data user can perform the actions you're trying to do.

I don't know if this is best practice (or if it'll work), but you could try switching to the www-data user.

Since you're already logged in as root, just enter:

su www-data

And you'll be typing commands on the command line as if you were the www-data user. Then try to render the image directly as you were before.

Ugh, that seemed like it would work. Text still not changing.

I got this from error report:

Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 34 Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 35 Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 36

Take a look at this:

http://php.net/manual/en/function.imagettftext.php

And make sure that the font exists on the system and that it's in the system path, looks like GDFONTPATH is the environment variable that GD uses to look at for fonts.

Lol, yeah in the eyes of a novice I have no idea what this means.

I have the font in the same directory. That wouldn't be enough?

I don't know how to make it clearer than this. Looks like you may need to do the trick they explain there to make PHP see the font file.

fontfile

The path to the TrueType font you wish to use.

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain spaces.

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

The fix was so simple!

Ugh, just had to add ./ to the beginning of the font name.

I didn't know…

Glad that's over.

Thanks for all your help.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct