title: The image cannot be displayed because it contains errors
body: <p>Why is this code not working ?</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  &lt;html&gt;
      &lt;head&gt;
  
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;?php
          header('Content-type: image/png');
          $myImage = imagecreate(200, 100);
          $myGray = imagecolorallocate($myImage, 204, 204, 204);
          $myBlack = imagecolorallocate($myImage, 0, 0, 0);
          imageline($myImage, 15, 35, 120, 60, $myBlack);
  
          imagepng($myImage);
          imagedestroy($myImage);
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I always get error <code>The image cannot be displayed because it contains errors.</code>. I've already enabled <code>php_gd2.dll</code> and <code>memory_limit</code> in php.ini is also 128M. If i remove <code>header('Content-type: image/png');</code> i don't get the error but i don't see the image either. All i see is this :-</p>
  
  <p><code>‰PNG  ��� IHDR���È���d���ùHíH���PLTEÌÌÌ���Ó33d���MIDATH‰c</code>£<code>Àx�§” Nf*k²Ã)Ãø�§”•5}À)ÅS†ÚšpJUà”a§²¦œ2ÔŽw&lt;špJ‚Q0 †;�� uTBúŸ����IEND®B</code>‚ `</p>