square instead of number


Posted on 16th Feb 2014 07:03 pm by admin

Hello
I do not know why but this code seems to work fine only in my xampp local insallation but not in the remote server. I just see a black square instead of the number 0000000 when I run this code in the remote server through the link http://www.arreglaordenador.com/numberimage.php

and the code in numberimage.php is:
Code: (text)
<?php
$fontDir = $rootPath . "fonts\";
$fn = (isset($_GET['fn'])) ? $_GET['fn'] : "ARIAL.ttf";
$fs = (isset($_GET['fs'])) ? $_GET['fs'] : 10;
$maxWidth = 80 * $fs;

//$colorArray = array ("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white", "gray");
$colorArray = array ("black", "black", "black", "black", "black", "black", "black", "black", "black");
$color = (isset($_GET['color'])) ? $colorArray[$_GET['color']] : $colorArray[rand(0, 8)];
$txt = (isset($_GET['txt'])) ? $_GET['txt'] : "0000000";
$coords = imagettfbbox($fs, 0, $fontDir . $fn, $txt);
$w = abs($coords[4]) + 8;
$h = abs($coords[5]) + 8;
$img = imagecreatetruecolor($w, $h);
$red = imagecolorallocate($img, 255,0,0);
$green = imagecolorallocate($img, 0,255,0);
$blue = imagecolorallocate($img, 0,0,255);
$cyan = imagecolorallocate($img, 0,255,255);
$magenta = imagecolorallocate($img, 255,0,255);
$yellow = imagecolorallocate($img, 255,255,0);
$black = imagecolorallocate($img, 0,0,0);
$white = imagecolorallocate($img, 255,255,255);
$gray = imagecolorallocate($img, 127,127,127);
$fill = ($color == "white") ? $black : $white;
imagefill($img, 0, 0, $fill);
$position = 4;
if (isset($_GET['position'])) $position = $_GET['position'];

imagettftext($img, $fs, 0, 0, $h-$position, $$color, "$fontDir$fn", $txt);

header("content-type: image/jpeg");
imagejpeg($img, "", 100);
imagedestroy($img);
?>


Does any of you have any suggestion?
Thanks

No comments posted yet

Your Answer:

Login to answer
50 Like 27 Dislike
Previous forums Next forums
Other forums

Need help with unexpected T-STRING error
I'm a newbie and I'm still learning PHP. However this error has me stumped. I've googled, searched t

Table trouble
i have been reading the forum for a few weeks and decided to join. i like the format and the advice

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.

How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and

Calculating n! using vector
#include
#include
#include

using

Table colours fail when extra row added
Hey Gurus,

I got a weird problem with formating the colour of a table made in php. Everything

Why use OOP?
Can someone explain to me why I should use OOP instead of procedure based code.

Im building a

mysql VARCHAR acting like INT
Hi, All.

I have a table that contains a varchar(10) column named weird_field. In this column

script and html conflict in trying to create a header.
I have an error is occurring because of an html webpage with a "php require" at the top of

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash