I need help with PHP GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Glome
Forum Newbie
Posts: 1
Joined: Sun Oct 24, 2010 12:51 pm

I need help with PHP GD

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: I need help with PHP GD

Post 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.
Post Reply