Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting this error:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\index.php:123) in C:\xampp\htdocs\sayfalar\detay.php on line 145

And my code:
[PHP] a - Pastebin.com[^]

What I have tried:

I tried what I thought but I can't do.
Posted
Updated 5-Apr-16 7:06am
Comments
Sergey Alexandrovich Kryukov 3-Apr-16 15:37pm    
This is because the headers are already sent. What's the problem?
—SA

You just need to understand what headers are and what HTTP response is. All PHP does is the creation of this response. And headers always come first. All the HTTP response content is written sequentially, top down, without a possibility to get back; however, you can, say, modify header information with header_remove.

So, imagine what happens if you echo some data. It means that it's too late to write any header, this step is already passed. Some headers are written implicitly; when you echo some data, and no headers are written, required headers are output first, and then goes the data you echo. Most likely, you created some output before trying to add/modify headers.

If you need to write your custom headers, it should be done in the very beginning of your PHP execution flow (that is not necessarily in first lines of PHP code, where you can have some declarations); it's important that you don't echo anything before you write headers. As soon as you created some output in the body of HTTP response, it's too late to add or modify headers.

See also:
PHP: header — Manual[^],
How to fix "Headers already sent" error in PHP — Stack Overflow[^].

—SA
 
Share this answer
 
v2
Try Checking your code for spaces, remove unnecessary spaces here

<?php include("fonksiyonlar/config.php"); ?>

<?php 
$id=$_GET['id'];
$iceriksorgu=mysql_query("Select * from icerikler where icerikID=$id");
$icerikSonuc=mysql_fetch_object($iceriksorgu);


No need of multiple declaration of php tags, since the code is entirely php, no html or js etc.

Also check config.php for spaces etc. If there is any session_start() function etc.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900