SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Nottingham, UK
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    header('Location: '.$HTTP_SERVER_VARS['HTTP_REFERER']) problem!!

    Im having trouble getting my script to do what i want it to do. I upload a file to a newsboard. when i select upload a script does some sql and then i want to return back to that page. the code i use is
    Code:
    header('Location: '.$HTTP_SERVER_VARS['HTTP_REFERER']); 
       exit;
    this isn't working is there an alternative for what i want to do?


    the error i get is

    Code:
    Cannot modify header information - headers already sent

    full code is:


    PHP Code:
    <?php
        
        
    //script written with the help of chapter 26 PHP & Web Development by Luke Welling 04/02/2005
        

        
    require('page.inc');
        
        require_once(
    'news_fns.php');
        
        
        
    $link_id db_connect();
        
        
    $now time();
        
        
    $story $_GET['story'];
        
    $query "update stories set published = $now
            where story_id = 
    $story";
        
    $result mysql_query($query$link_id);

        
    header('Location: '.$HTTP_SERVER_VARS['HTTP_REFERER']);
        exit;
            
    ?>

  2. #2
    SitePoint Addict trogdor1024's Avatar
    Join Date
    Oct 2004
    Location
    New Jersey
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there anything in your "page.inc" or "news_fns.php" that tries to echo out something or send out other header info?

  3. #3
    SitePoint Addict Fire59's Avatar
    Join Date
    Aug 2003
    Location
    mn
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What trogdor said above or if you have a database query error.

  4. #4
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are running on PHP >= 4.1.0, use $_SERVER rather than $HTTP_SERVER_VARS

    There can be absolutley no output whatsoever (inclding blank lines, spaces etc) before the header call.
    Last edited by swdev; Jan 5, 2005 at 08:57. Reason: typo

  5. #5
    SitePoint Addict Chillijam's Avatar
    Join Date
    Nov 2003
    Location
    England
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your mind is like a parachute. It works best when open.
    (HH The Dalai Lama)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •