Hello People,
I am making a new design, and I was planning on using GD images for the headers. But I have ran into a problem.
I have this php page for the GD :
<?php
function drawImg($inpt, $inpt2) {
//Image Size (width,height)
$img_number = imagecreate(300,60);
//Colours
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$blue = imagecolorallocate($img_number,186,228,240);
$pink = imagecolorallocate($img_number,118,145,173);
$brown = imagecolorallocate($img_number,207,183,152);
//Background Colour
imagefill($img_number,0,0,$brown);
//Messages
$text = $inpt;
$text2 = $inpt2;
//Text colour
$tcolor = $black;
$tcolor2 = $pink;
//text stuff.
Imagettftext($img_number, 15,0,10,25,$tcolor,'trebuc.ttf',$text);
Imagettftext($img_number, 15,0,10,43,$tcolor2,'trebuc.ttf',$text2);
//Type of image
header("Content-type: image/png");
imagepng($img_number);
}
?>
and this is how I’m trying to use it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Strokemymouse</title>
<link href="images/STYLE.CSS" rel="stylesheet" type="text/css" />
<?php include('images/titlegd.php'); ?>
</head>
<body>
<div id="wrap">
<div class="header"></div>
<div class="nav"><ul id="navlist">
<li><a href="#">Home</a></li>
<li><a href="#">Work</a></li>
<li><a href="#">Stuff</a></li>
<li><a href="#">Web Design</a></li>
<li><a href="#">Contact</a></li>
</ul></div>
<div class="content"><?php drawImg("Test", "not worky"); ?></div>
</div>
</body>
</html>
But using that method gives me an error:
The image “http://localhost/design/” cannot be displayed, because it contains errors.
How can I solve this?
Sorry guys, Found a solution.
I use it like this:
<img src=“images/titlegd.php?inpt=thanks&inpt2=anyway” />