floppydrivez Posted February 19, 2007 Share Posted February 19, 2007 A little tuff to explain, but this is not working on some servers. This is the code // Split the HTML color representation $bgcolor = $_GET['bgcolor']; $tcolor = $_GET['tcolor']; function string_split($str, $nr){ return split("-l-", chunk_split($str, $nr, '-l-')); } $hexcolor1 = string_split($bgcolor, 2); $hexcolor2 = string_split($tcolor, 2); // Convert HEX values to DECIMAL $bincolor1[0] = hexdec("0x{$hexcolor1[0]}"); $bincolor1[1] = hexdec("0x{$hexcolor1[1]}"); $bincolor1[2] = hexdec("0x{$hexcolor1[2]}"); $bincolor2[0] = hexdec("0x{$hexcolor2[0]}"); $bincolor2[1] = hexdec("0x{$hexcolor2[1]}"); $bincolor2[2] = hexdec("0x{$hexcolor2[2]}"); $font = 2; $width = strlen($protect_string) * ImageFontWidth($font); $height = ImageFontHeight($font); $im = @imagecreate ($width,$height); //Create background $background_color = ImageColorAllocate($im, "$bincolor1[0]", "$bincolor1[1]", "$bincolor1[2]"); //Create Text $text_color = ImageColorAllocate($im, "$bincolor2[0]", "$bincolor2[1]", "$bincolor2[2]"); imagestring ($im, $font, 0, 0, $protect_string, $text_color); imagejpeg ($im); ImageDestroy($im); Below are the errors Warning: imagecolorallocate(): supplied argument is not a valid Image resource in ../Clan_Roster/files/protect.php on line 24 Warning: imagecolorallocate(): supplied argument is not a valid Image resource in ../Clan_Roster/files/protect.php on line 26 Warning: imagestring(): supplied argument is not a valid Image resource in ../Clan_Roster/files/protect.php on line 27 Warning: imagejpeg(): supplied argument is not a valid Image resource in ../Clan_Roster/files/protect.php on line 28 Warning: imagedestroy(): supplied argument is not a valid Image resource in ../Clan_Roster/files/protect.php on line 29 It works fine on some servers and not on others. Does anyone know what might be causing this not to work on some? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 19, 2007 Share Posted February 19, 2007 It's more likely the error reporting levels are different on the servers, and you only see the warnings on some. You're surpressing the error that actually matters: $im = @imagecreate ($width,$height); Needs to be : $im = imagecreate ($width,$height); In order to get an error that will help. Quote Link to comment Share on other sites More sharing options...
floppydrivez Posted February 19, 2007 Author Share Posted February 19, 2007 Results Warning: imagecreate() [function.imagecreate]: Invalid image dimensions in ../Clan_Roster/files/protect.php on line 22 So there is an error in the width or height generated? Any suggestions? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 19, 2007 Share Posted February 19, 2007 $width = strlen($protect_string) * ImageFontWidth($font); Where's $protect_string defined? If it's not, that will give you 0*# = 0, so you get a 0 width. Quote Link to comment Share on other sites More sharing options...
floppydrivez Posted February 19, 2007 Author Share Posted February 19, 2007 http://www.testing.com/modules/Clan_Roster/files/protect.php?protect_string=Keeper32@gmail.com&bgcolor=6699CC&tcolor=EEEEEE Like I said I have it working on serveral servers Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 19, 2007 Share Posted February 19, 2007 $protect_string = $_GET['protect_string']; You have to $_GET a variable from the URL, you can't depend on Register_globals being on. Quote Link to comment Share on other sites More sharing options...
floppydrivez Posted February 19, 2007 Author Share Posted February 19, 2007 Man, skipped right over that. Thanks I learned a lot today. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 19, 2007 Share Posted February 19, 2007 Just because something works on one server doesn't mean it will on another. You're depending on several INI settings that can easily vary server to server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.