PHP headers already sent Error

I have this error and it is driving me crazt. I don't know why it is happening:

"Warning: Cannot modify header information - headers already sent by (output started at /admin/db_connect.php"

I have checked for spaces before the php tags in the file and the db_connect file.

My includes look like this:

<?php
include("../pChart2.1.1/class/pData.class.php");
include("../pChart2.1.1/class/pDraw.class.php");
include("../pChart2.1.1/class/pImage.class.php");
include("../admin/db_connect.php");

$GrabIt = $_GET["test"];  

And then some DB query.

What am I doing wrongly?

Thanks.
SolutionabcAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lukasz ChmielewskiCommented:
You need to show us the db_connect.php and also the rest of the script. If it says it has already outputted the header then it did. Some of the connection command may do that.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
greenbug2002Commented:
somthing in one of those files must be returning data to the webbrowser for the headers alredy sent warning to be triggered try comenting out each include to narrow it down
0
AriMcCommented:
Also check all of your PHP-files for empty lines before and after the starting and ending tags

<?php
?>

0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Beverley PortlockCommented:
The clue to the error is given by this partially complete error line

output started at /admin/db_connect.php

This error normally has some additional text that should look like this

output started at /admin/db_connect.php at line 1234

and that indicates the line of the script that commenced the output. The output could be as simple as a blank line before a <?php tag or after a ?> tag or an echo or some HTML. You have two choices at this point

1. Stop the line in question from outputting text.

2. At the top of the very first script add this line as early as possible

ob_start();

Like so

<?php
   ob_start();
   ... etc....

http://www.php.net/ob_start
0
Ray PaseurCommented:
ob_start() may do the trick for you, but here is what I would do.

Run the code snippet - and that is all - and look at the browser output with "view source."  You may find the output in there!  And if it is useless, eliminate it.
<?php
include("../pChart2.1.1/class/pData.class.php");
include("../pChart2.1.1/class/pDraw.class.php");
include("../pChart2.1.1/class/pImage.class.php");
include("../admin/db_connect.php");
die();

Open in new window

0
SolutionabcAuthor Commented:
I tried bportlock suggestions and got a message that says:
"The image "http://www...etc/index.php/get=test" cannot be displayed because it contains errors.

I tried Rays and nothing appeared in the source.

It looks like the script that is dependent on the include class files does not like any output before it is run.
that script draws a graph and outputs it as an image.

I have some db queries that output some information before the image should display. If I put the image script before the output text the image will work but the output text does not show.

any suggestions?
thanks!
0
Ray PaseurCommented:
any suggestions?

Yes, here is a suggestion.  Please do not waste your time and ours with things like "http://www...etc/index.php/get=test".  Instead tell us the complete information -- the actual URLs, the full error messages.  There is little point in making us guess blindly, when if you give us the information we can look and see, and maybe help find a solution.
0
SolutionabcAuthor Commented:
I blanked out the url. How is listing the full URL going to help you help me?

The parameter being passed to it would be the only useful thing if even that.... and it was included above.

0
SolutionabcAuthor Commented:
anyways, I got it.. ended up putting EVERYTHING into an include file and called it in with an img tag.

thx.
0
Ray PaseurCommented:
Yes, I know you blanked out the URL.  How will anyone here at EE be able to see the web page and the generated HTML?  
0
SolutionabcAuthor Commented:
If seeing the generated html was important to you then I would rather copy and paste it into here.

thx.
0
Ray PaseurCommented:
@Solutionabc: The point is rather simple.  The more you hide from us, the less likely we are to be able to help you.  The more you show us, the more likely we are to be able to help you.  We are only experts, not clairvoyant, and we cannot guess about what might or might not be happening in a script when we cannot see the script and we cannot see the output.  

Imagine a chef who said, "My diners say the meatloaf tastes rancid.  What is wrong?"  When we get partial error messages and no visibility of the cause, we have no more information than we would for the chef.  So please give us all the details.   If you have data that you want to protect, copy it, obscure it, and make a test case that demonstrates the problem.  Often you will find (at least I do) that preparing an isolated test case is all you need to do to solve the problem!

Best of luck with it, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.