Page 1 of 4

GD - Picture not being shown

Posted: Mon Feb 23, 2004 8:32 am
by Straterra
I have this code, but when you try to load the image, it won't load! I get a red X!

Code: Select all

<?php 
$val = file("imagecounter.txt"); 
$num = $val[0]; 
$num++; 
$fp = fopen( "imagecounter.txt", "w" ); 
fwrite( $fp, $num ); 
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); 
header ("Content-type: image/png"); 
$img_handle = ImageCreate (400, 110) or die ("Cannot Create image"); 
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10); 
$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255); 
ImageTTFText ($img_handle, 9, 0, 5, 20, $txt_color, "/WINDOWS/Fonts/IMPACT.ttf", 
              "IP : ".$_SERVER['REMOTE_ADDR']); 
ImageTTFText ($img_handle, 9, 0, 5, 40, $txt_color, "/WINDOWS/Fonts/IMPACT.ttf", 
              "HostName : ".$hostname); 
ImageTTFText ($img_handle, 9, 0, 5, 60, $txt_color, "/WINDOWS/Fonts/IMPACT.ttf", 
              "Referer : ".$_SERVER['HTTP_REFERER']); 
ImageTTFText ($img_handle, 9, 0, 5, 80, $txt_color, "/WINDOWS/Fonts/IMPACT.ttf", 
              "User Agent : ".$_SERVER['HTTP_USER_AGENT']); 
ImageTTFText ($img_handle, 9, 0, 5, 100, $txt_color, "/WINDOWS/Fonts/IMPACT.ttf", 
              "You are viewer number $num"); 
ImagePng ($img_handle); 
?>

Posted: Mon Feb 23, 2004 9:33 am
by tsg
What if you change:
ImageCreate (400, 110)

to
ImageCreatefrompng (400, 110)

Posted: Mon Feb 23, 2004 9:36 am
by Derfel Cadarn
Hey Straterra, isn't that the code you use in your signature here? Seems to work fine! :wink:

Posted: Mon Feb 23, 2004 4:08 pm
by Straterra
Yeah, that is the code..but when I try to view it in a browser, it doesn't work!

Posted: Mon Feb 23, 2004 4:12 pm
by Straterra
And TSG, it returns an error.

Posted: Tue Feb 24, 2004 3:34 am
by Derfel Cadarn
Do you mean you don't see the image when you visit this thread? Or when you run it from your own server? Can it have anything to dowith th fonts being not in that dir? :oops:

Posted: Tue Feb 24, 2004 3:41 am
by vigge89
he means that it doesn't work when just viewing the image, which it doesn't for me either...

Posted: Tue Feb 24, 2004 3:48 am
by McGruff
Please remove that. You do not have permission to run additional scripts or attempt to set cookies for visitors to phpdn.

Posted: Tue Feb 24, 2004 5:35 am
by Straterra
Wha? Remove...what? Cookies?

Posted: Tue Feb 24, 2004 6:27 am
by McGruff
Your image link runs a script on your site. Your site attempts to set a cookie.

Please remove this.

Posted: Tue Feb 24, 2004 9:09 am
by Straterra
Um...The website isn't mine, though I host it. The only file that I have is the draw.php, which draws the GD thing. It has no cookie..I don't know what you are talking about. What I posted is all to the code.

Posted: Tue Feb 24, 2004 9:21 am
by McGruff
For the third time, would you please remove this signature?

Posted: Tue Feb 24, 2004 9:24 am
by Straterra
It doesn't use a cookie. Would you like me to send you the draw.php file? Because I will!

Posted: Tue Feb 24, 2004 9:25 am
by McGruff
Remove it now please.

Posted: Tue Feb 24, 2004 9:28 am
by Straterra
What's your email? I will email you the file. No one else complains of it setting a cookie. I will look right now on this machine and see if it set a cookie.