Page 1 of 1

I need help with PHP GD

Posted: Sun Oct 24, 2010 12:56 pm
by Glome
I am creating a avatar site and I am always having this problem with my PHP code.

Code: Select all

<?php
require 'connect.php';
$id = mysql_real_escape_string($_GET['id']);
$getuser = mysql_query("SELECT * FROM `users` WHERE `ID` = '$id'");
$row = mysql_fetch_array($getuser);
$check = mysql_num_rows($getuser);
if($check == 0) {
die("Requested user does not exist!");
}

 $base = imagecreatefrompng("Images/Avatar/Base/avatar.png");
 
 if($row['hat'] == NULL) {
  $hat= imagecreatefrompng("Images/Avatar/Base/blank.png");
 } else {
 $hat= imagecreatefrompng("Images/Avatar/Items/".$row['hat']."");
 }
header('content-type: image/png'); 
 imagecopymerge($base, $hat, 0, 0, 0, 0, 125, 200, 100);


 imagepng($base);
 ?>
It layers just fine if I create the images on my computer and upload them, but if my friend uploads an item and puts it on the avatar just turns blank. The weird thing is if I save the item my friend uploads and open it on my paint.net and save it again and re upload it it will start to work again.

Anyone know why this is happening?

Re: I need help with PHP GD

Posted: Sun Oct 24, 2010 11:59 pm
by requinix
Most obvious possibility: is he uploading an image in the wrong format? Just because it has a .png extension does not mean it's a PNG - MS Paint, for one, is horrible with that.