Results 1 to 2 of 2

Thread: Getting blank page after program runs

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    99
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Getting blank page after program runs

    I run my php program, update my database, and send some emails. After that, I want to return to my front page. The end of my program is:

    mail($to,$subject,$message,$emailheader);
    mail($to2,$subject,$message2,$emailheader);
    header('Location: index.htm');
    ?>

    If I leave out the "header" line, the emails are sent but I get a blank page that I have to back out of.
    If I leave it in, the emails are still sent but I get error message:
    Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/public_html/pdoinfoupdate2.php:2) in /home/xxxx/public_html/pdoinfoupdate2.php on line 87 (line 87 is the header line)

    I've tried exit, die, and a hundred different things. Any help would be useful
    Last edited by mcolton; 06-16-2014 at 06:34 PM.

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    The error occurs when you have output to the browser before using the header(). Meaning ANYTHING, including doctype, <html>, etc, that is produced and output to the browser in the source code before the header() will cause this error. You need to do all your php processing before any output. The other more frowned upon way to fix it is to put this line at the very top of the page above everything else that your site includes(), requires(), etc.
    PHP Code:
    ob_start(); 
    You never know everything, I learn everyday!

Similar Threads

  1. FadeSlideShow problem - just getting a blank page - why?
    By CountryGirl in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 08-30-2010, 09:10 PM
  2. php script shows blank page
    By matthewbluewars in forum PHP
    Replies: 11
    Last Post: 05-01-2008, 11:37 PM
  3. Blank page because of an echo
    By naiani in forum PHP
    Replies: 10
    Last Post: 09-01-2007, 07:56 PM
  4. Replies: 6
    Last Post: 07-05-2007, 08:54 AM
  5. Blank Page on internet
    By rob11 in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 05-11-2007, 04:03 PM

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
  •