# \[php\] Using GD in a HTML page

**URL:** <https://forum.kirupa.com/t/php-using-gd-in-a-html-page/259444>\
**Category:** Uncategorized\
**Created:** [May 5, 2008, 2:32pm UTC](https://forum.kirupa.com/t/php-using-gd-in-a-html-page/259444 "2008-05-05T14:32:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisclick](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/chrisclick/32/1991_2.png) [@chrisclick](https://forum.kirupa.com/u/chrisclick)\
**Post date:** [May 5, 2008, 2:32pm UTC](https://forum.kirupa.com/t/php-using-gd-in-a-html-page/259444/1 "2008-05-05T14:32:06Z")

</div>

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

<?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.

```auto

<!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:

```auto

The image &#8220;http://localhost/design/&#8221; 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” /\>
