andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Header redirect erroring

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
cesarcesar
Newbie


Joined: 26 Apr 2006
Posts: 2
Location: Portland, Oregon, USA

PostPosted: Wed Apr 26, 2006 1:51 pm    Post subject: Header redirect erroring Reply with quote

When processing this code -
Code:
<?php

    require_once 'class.cropinterface.php';
    $ci =& new cropInterface();
   
    if ($_GET['file']) {
        $ci->loadImage($_GET['file']);
        $ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
        $ci->saveImage('mysavedimage.jpg');
        header('Location: crop.php');
        exit;
    }

?>
<html>
<body>

    <?php

        $ci->loadInterface('mypicture.jpg');
        $ci->loadJavaScript();

    ?>

</body>
</html>


I get the follwing error -
Code:


Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/*****.net/httpdocs/dev/crop_resize/class.cropcanvas.php:2) in /var/www/vhosts/*****.net/httpdocs/dev/crop_resize/crop.php on line 13


line 13 is - header('Location: upload.php');

I have made sure there are no whitespaces in my code.

Without the header() function it works perfectly.

Thanks again for the help and this great script.
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Apr 28, 2006 10:21 am    Post subject: Reply with quote

Unless you're using output buffering, changing the location via a header request isn't going to work if you've already put information to the browser because this sets the headers and you cannot then change that. Any characters - even white space (space, tab, carriage return, etc.) - count as content and would set your content-type header to something like text/html.

Looking at your warning message is says:

Quote:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/*****.net/httpdocs/dev/crop_resize/class.cropcanvas.php:2) in


This says that you have output something on line 2 of the class.cropcanvas.php file. You probably have a blank line at the top of that file. Remove that so the PHP tag is the first thing in the document (and the closing PHP tag the last thing in the document - no new line after that either!) and you should be ok.

If you use output buffering then it's not really an issue.

http://uk.php.net/manual/en/ref.outcontrol.php

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group