I am using below captcha.Its working fine in localhost,one server.The problem is same code is not running on different server.
Need suggestion

$ranStr = md5(microtime());
$ranStr = substr($ranStr, 0, 6);
$_SESSION['cap_code'] = $ranStr;
$newImage = imagecreatefromjpeg("img/cap_bg1.jpg");
$txtColor = imagecolorallocate($newImage, 0, 0, 0);
imagestring($newImage, 5, 5, 5, $ranStr, $txtColor);
header("Content-type: image/jpeg");

What is the problem ?

Server error
The website encountered an error while retrieving http://pghostels.co.in/pgfinal/pgfinal2/admin/captcha.php. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.

Its working fine in one server.but getting above error while executing on different server

Both don't work for me. If one works, then it could be some server setting. Does one use a htaccess for example, that may get in the way.

Do you have the GD library installed on the server where it isn't working?

Do you have the GD library installed on the server where it isn't working?

How to install all this

FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9

I installed gd library & getting below.
I am showing text on image.Is there any need of free type support or free type linkage.

Need suggestion
GD Support enabled
GD Version bundled (2.0.34 compatible)
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XPM Support enabled
XBM Support enabled