tags:

views:

46

answers:

3

php code-

$q = "Update tblarticle set art_title='$title', art_cat='$cat', art_des='$txtart' where art_id='".$_GET['art_id']."'";
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if($result)
{
    //saved succesfullt
    $error =0;
    header("location:mngArt.php");
    exit;
}
else $error =1;
}
?>  
....Some HTML........

database is getting updated but Cannot modify header information error msg is popping up.

A: 

There cannot be anything outside the closing PHP tag if you want to modify the headers. So the HTML outside the ?> will be causing that warning.

MRW
That is not true. There cannot be anything that is not a header output to the client before headers. So any output before the `header` function call will cause the error. Anything after the `?>` in the OP is fine.
Matt Ellen
+1  A: 

The reason is that at some point something is output to the screen. This could be anything from a full website to a tiny space or newline character(s).

Important: Unlike what MRW said, there must not be any HTML before calling that function. After calling it, you can do anything you want.

So it is the code before <?php that is the issue, not the one after ?>.

Christian Sciberras
A: 

The easiest way to fix it is to add this to the very top of your file:

<?php
ob_start();
That will only complicate your code and make scripts less responsive.
Christian Sciberras
Doesn't "fix" it, simply hides it
Mark Baker
Output buffering should not be applied as an easy fix. Instead, use it to serve a specific purpose - not to eliminate the need to refactor badly designed code.
jensgram