Jump to content
xisto Community
moldboy

Php And Gd Tutorial Im having problems

Recommended Posts

Delete the blank line before the <?php tag. This should fix your header errors because once anything is written to the browser, php cannot edit header information of the page like the location and such. Most likely they just didnt use the code tag correctly when posting the tutorial on that website

Share this post


Link to post
Share on other sites

Okay I think I know what you mean about blank lines. So this is what my code looks like (the php is from the second page)

<html><head><title></title></head><body bgcolor="#FFFFFF"><?php Header("Content-type: image/png"); $height = 300; $width = 300; $im = ImageCreate($width, $height); $bck = ImageColorAllocate($im, 10,110,100); $white = ImageColorAllocate($im, 255, 255, 255); ImageFill($im, 0, 0, $bck); ImageLine($im, 0, 0, $width, $height, $white); for($i=0;$i<=299;$i=$i+10) { ImageLine($im, 0, $i, $width, $height, $white); }     ImagePNG($im); ?></body></html>
but I still get a header error, says there is something wrong with line 7.

Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/phptest/php2.php:6) in /home/moldboy/public_html/phptest/php2.php on line 7

Could it be the way the GD tool set is set up on Xisto?

Share this post


Link to post
Share on other sites

hi there .. i've always seen this problem ... always got a header error ... but i do not know the cause of it .. but i might have a solution to it ... It happens that whenever i changed my file content online ... i will get a header error on my php file that i edited ... so i tried to edit them offline and upload them .. and no more header error ... this works for me .. may be you can try this out ... just do everything offline on your computer .. and upload the final file to the server :D Do let me know if this works

Share this post


Link to post
Share on other sites

no

 

what you have to do, is always with headers like this and session_start() is put them in the very top of your page, so the first thing in your script should be:

<?phpsession_start();Header("Content-type: image/png"); ?><html>//your html...
in your script you dont need session_start, so take it off and you got your fix, it's a must for php scripts to have these kinda things at the very top, else it causes 'cannot modify header- headers already sent' errors

Share this post


Link to post
Share on other sites

You can try making a backup files and edit it offline... I often have this error and usually edit the backup files in my harddisk then upload it to my server... That's saves everything... Or maybe you can clear your cache...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.