Adobe Dreamweaver Forums



Last 10 THreads :         Frontpage applets to DW?? (Last Post : Alan - Replies : 1 - Views : 2 )           »          RoboHelp hanging (Last Post : shawntrident - Replies : 6 - Views : 7 )           »          RoboHelp & Knowledge Bases (Last Post : Captiv8r - Replies : 3 - Views : 4 )           »          Re: export image in D11 (Last Post : DAVID NAJAR - Replies : 1 - Views : 2 )           »          Cannot import audio into Captivate 3.0 (Last Post : ebowman77 - Replies : 2 - Views : 3 )           »          Dreamweaver MX vs Dreamweaver 4 (Last Post : bw75 - Replies : 0 - Views : 1 )           »          this will come in handy here. (Last Post : P@tty Ayers ~ACE - Replies : 9 - Views : 10 )           »          Seeking advise on flv in Captivate 3 (Last Post : 9060 - Replies : 0 - Views : 1 )           »          Global variables (Last Post : jfb00 - Replies : 0 - Views : 1 )           »          catching errors from remotely invoked processes (Last Post : Cr99 - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 01:49 PM
Brett
 
Posts: n/a
Diggs:
Default Dreaded "headers already sent" error

I'm getting a "headers already sent" error and I can't figure out why.
I have checked for and eliminated all whitespace in my php include files
and still I'm getting the error:

> Warning: Cannot modify header information - headers already sent by
> (output started at
> /Users/brett/vhosts/modules/admin/Products/add_div .inc.php:51)
> in /Users/brett/vhosts/modules/admin/Products/update_ grp.inc.php on
> line 44



After updating a table record, I am trying to redirect to a page
containing accordion panels populated with table LIST pages. Here is my
redirect:

>
> if ($Result1) {
> header('Location: http://' . $_SERVER['HTTP_HOST'] .
> dirname($_SERVER['PHP_SELF']) .
> '/admin.php?content=Products/seeSelections');
> exit;
> }



I have looked at the include file listed in the error message and can
find no problem. Here is the code:

> <?php
> if (!function_exists("GetSQLValueString")) {
> function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
> $theNotDefinedValue = "")
> {
> $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) :
> $theValue;
>
> $theValue = function_exists("mysql_real_escape_string") ?
> mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
>
> switch ($theType) {
> case "text":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "long":
> case "int":
> $theValue = ($theValue != "") ? intval($theValue) : "NULL";
> break;
> case "double":
> $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'"
> : "NULL";
> break;
> case "date":
> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "defined":
> $theValue = ($theValue != "") ? $theDefinedValue :
> $theNotDefinedValue;
> break;
> }
> return $theValue;
> }
> }
>
> $editFormAction = $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
> }
>
> if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "addDiv")) {
> $insertSQL = sprintf("INSERT INTO divisions (div_name) VALUES (%s)",
> GetSQLValueString($_POST['div_name'], "text"));
>
> mysql_select_db($database_testadmin, $testadmin);
> $Result1 = mysql_query($insertSQL, $testadmin) or die(mysql_error());
> }
> ?>
> <form id="addDiv" name="addDiv" method="POST" action="<?php echo
> $editFormAction; ?>">
> <label for="div_name">Name:</label>
> <br />
> <input type="text" name="div_name" id="div_name" />
> <br /><br />
> <input type="submit" name="submit" id="submit" value="Add entry" />
> <input name="MM_insert" type="hidden" id="MM_insert" value="addDiv" />
> </form>


Line 51 in "add_div.inc.php" is the last line shown above - </form> -
and there is no whitespace after the closing >.
Line 44 in "update_grp.inc.php" is the header redirect shown above.
What could be the problem?

TIA

Brett



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-01-2008, 01:49 PM
David Powers
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

Brett wrote:
> I'm getting a "headers already sent" error and I can't figure out why.
> I have checked for and eliminated all whitespace in my php include files
> and still I'm getting the error:
>
>> Warning: Cannot modify header information - headers already sent by
>> (output started at
>> /Users/brett/vhosts/modules/admin/Products/add_div .inc.php:51)
>> in /Users/brett/vhosts/modules/admin/Products/update_ grp.inc.php on
>> line 44


The error message says that output was started on line 44 of
update_grp.inc.php. That's where you should look for the problem.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Reply With Quote
  #3 (permalink)  
Old 10-01-2008, 01:49 PM
David Powers
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

Brett wrote:
> I'm getting a "headers already sent" error and I can't figure out why.
> I have checked for and eliminated all whitespace in my php include files
> and still I'm getting the error:
>
>> Warning: Cannot modify header information - headers already sent by
>> (output started at
>> /Users/brett/vhosts/modules/admin/Products/add_div .inc.php:51)
>> in /Users/brett/vhosts/modules/admin/Products/update_ grp.inc.php on
>> line 44


The error message says that output was started on line 44 of
update_grp.inc.php. That's where you should look for the problem.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Reply With Quote


  #4 (permalink)  
Old 10-01-2008, 01:49 PM
Brett
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

Thanks David, I looked at line 44:

> if ($Result1) {
> header('Location: http://' . $_SERVER['HTTP_HOST'] .
> dirname($_SERVER['PHP_SELF']) .
> '/admin.php?content=Products/seeSelections');
> exit;
> }


but I don't see where the problem is. Line 44 starts with:
header('Location: ...etc. as shown above. I have used this code on many
other pages and it works fine, why not here?

Best,

Brett
Reply With Quote
  #5 (permalink)  
Old 10-01-2008, 01:49 PM
Brett
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

Thanks David, I looked at line 44:

> if ($Result1) {
> header('Location: http://' . $_SERVER['HTTP_HOST'] .
> dirname($_SERVER['PHP_SELF']) .
> '/admin.php?content=Products/seeSelections');
> exit;
> }


but I don't see where the problem is. Line 44 starts with:
header('Location: ...etc. as shown above. I have used this code on many
other pages and it works fine, why not here?

Best,

Brett
Reply With Quote
  #6 (permalink)  
Old 10-01-2008, 01:49 PM
David Powers
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

Brett wrote:
> but I don't see where the problem is. Line 44 starts with:
> header('Location: ...etc. as shown above. I have used this code on many
> other pages and it works fine, why not here?


As always with PHP error messages, you need to start working backwards
from that point. One thing I would suggest looking for is the use of the
Byte Order Mark. In each page, select Modify > Page Properties. In the
Title/Encoding section, make sure that Include Unicode Signature (BOM)
is deselected.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Reply With Quote


  #7 (permalink)  
Old 10-01-2008, 01:49 PM
Brett
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

David,

I found the solution to my problem. I needed to use output buffering to
prevent headers being sent.
What I did was place ob_start() at the beginning of the page with all of
the accordion elements, and ob_end_flush() at the very end. Now when I
edit a record in one accordion panel and click update, I'm redirected to
the same page with the default settings for all panels and the record
shows the update.

Whew! That's a relief!

As always, thanks for taking the time to help.

Best,

Brett
Reply With Quote
  #8 (permalink)  
Old 10-01-2008, 01:49 PM
Brett
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

David,

I found the solution to my problem. I needed to use output buffering to
prevent headers being sent.
What I did was place ob_start() at the beginning of the page with all of
the accordion elements, and ob_end_flush() at the very end. Now when I
edit a record in one accordion panel and click update, I'm redirected to
the same page with the default settings for all panels and the record
shows the update.

Whew! That's a relief!

As always, thanks for taking the time to help.

Best,

Brett
Reply With Quote
  #9 (permalink)  
Old 10-01-2008, 01:49 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

..oO(Brett)

>I found the solution to my problem. I needed to use output buffering to
>prevent headers being sent.


No. It's an ugly workaround, but doesn't fix the real problem. You
should re-order your code so that all tests and calculations happen
before the first line of output.

Micha
Reply With Quote


  #10 (permalink)  
Old 10-01-2008, 01:49 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: Dreaded "headers already sent" error

..oO(Brett)

>I found the solution to my problem. I needed to use output buffering to
>prevent headers being sent.


No. It's an ugly workaround, but doesn't fix the real problem. You
should re-order your code so that all tests and calculations happen
before the first line of output.

Micha
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 08:33 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk