Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Banned
    Join Date
    Aug 2003
    Posts
    12
    Member #
    2580
    My page keeps outputting an error message:

    http://www.adtoolbox.com/temp/affiliate.php


    The errors should look like this.
    Warning: Cannot modify header information - headers already sent by (output started at /home/adtoolbo/public_html/temp/affiliate.php:2) in /home/adtoolbo/public_html/temp/affiliate.php on line 13

    Warning: Cannot modify header information - headers already sent by (output started at /home/adtoolbo/public_html/temp/affiliate.php:2) in /home/adtoolbo/public_html/temp/affiliate.php on line 14

    Warning: Cannot modify header information - headers already sent by (output started at /home/adtoolbo/public_html/temp/affiliate.php:2) in /home/adtoolbo/public_html/temp/affiliate.php on line 15

    Warning: Cannot modify header information - headers already sent by (output started at /home/adtoolbo/public_html/temp/affiliate.php:2) in /home/adtoolbo/public_html/temp/affiliate.php on line 16


    All this php page does is set cookies, but for some reason, it's not working, and I have deadlines and this is really starting to scare me. Any Godsends out there, that know the solution to this problem?

    Thanks!

    Greg J
    design@new-point-0.com

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    You're probably trying to set a cookie after you've sent some html, you can't do this! A header information is something like "404 Page not Found" or "200 OK"... it's something that's sent before the page is sent. To avoid those errors, use output buffering. At the beggining of the script put:

    ob_start();

    And at the end put:

    ob_flush();
    This way PHP reorginaizes it so the headers are sent first no matter where they are in the document.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Banned
    Join Date
    Aug 2003
    Posts
    12
    Member #
    2580
    Hey brak, thx for the suggestion but unfortunately, that didn't work. Maybe I didn't provide enough information?

    Here is the php script I'm trying to run:

    <?php
    $cookie_life = time() + 31536000;
    $path = '/';
    $hostname = 'hypnoticwritingwizard.com';

    $username = $_GET['username'];
    $password = $_GET['password'];
    $offercode = $_GET['offercode'];


    setcookie('username', $username, $cookie_life, $path, $hostname);
    setcookie('password', $password, $cookie_life, $path, $hostname);
    setcookie('offercode', $offercode, $cookie_life, $path, $hostname);
    header("Location: http://www.http://www.hypnoticwritingwizard.com/");
    ?>

    Does that change the situation at all?

    Greg

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Do you have any whitespace before the <?php or after the ?>?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Any html or text before your opening <?php will create an output buffer, which will not allow you to write to the header of the document anymore (cookies write to the header). Put any html AFTER the cookie-writing block and you'll fix your error


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:11 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com