title: My thumbnail function is't working properly
body: <p>When this code runs the browser screen turns black with a grey and white checkered square in the middle when it is suppose to display a thumbnail within a table cell on a form.</p>
  
  <pre><code>function createThumb( $imageUrl, $thumbWidth ) 
  { 
  
  // load image and get image size
  $img = imagecreatefromjpeg( $imageUrl );
  $width = imagesx( $img );
  $height = imagesy( $img );
  
  // calculate thumbnail size
  $new_width = $thumbWidth;
  $new_height = floor( $height * ( $thumbWidth / $width ) );
  
  // create a new temporary image
  $tmp_img = imagecreatetruecolor( $new_width, $new_height );
  
  // copy and resize old image into new image 
  imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
  
  // display thumbnail
  header("Content-type:image/jpeg");
  imagejpeg( $tmp_img,$imageUrl,80);
  };
  </code></pre>
  
  <p>And the line that calls the code is</p>
  
  <pre><code>&lt;td &gt;
  &lt;?php echo createThumb("CoffeeReg.jpg",75)?&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>I haven't found any of the normal syntax errors, and the code even comes back clean when ran through a syntax checker so that leads me to believe either its a problem with my logic, I'm using the built in functions incorrectly or I have messed up something in the way I am trying to display the new thumbnail only with my lack of exp I don't see where I went wrong. I need to know what I did wrong so I can learn from this mistake.</p>