<? ob_start(); ?><?php //session_start();
include('ziplib.php');
//require 'database.php';
	//require 'zip/gnu-lgpl.txt';
	require 'zip/pclzip.lib.php';
//
if($_POST['download']) // from button name="delete"
	{
		$checkbox = $_POST['checkbox']; //from name="checkbox[]"
		$countCheck = count($_POST['checkbox']);

		for($i=0;$i<$countCheck;$i++)
		{
			$del_id  = $checkbox[$i];
							if(isset($_GET['del_id']))
						{
						$id      = $_GET['del_id'];
						$query   = "SELECT * FROM updatenews WHERE id = $del_id";
						$result  = mysqli_query('$query') or die('Error, query failed');
						list($filename, $type, $size, $content) = mysqli_fetch_array($result);
						//header("Content-type: Content-Type: application/msword; charset=ISO-8859-1");
						//header("Content-Disposition: attachment; filename=\"$filename\"");
						//header("Content-length: $size");
						//echo "$content";
				//echo "$query";

						}
			if(!$result)
				{
				echo "$del_id";
				$con=mysql_connect('localhost','wwwpmni_root','vertrigo123./.');
if(!$con)
{
die('could not connect:' .mysql_error());
}
mysql_select_db('wwwpmni_pmn',$con);;

$sql = "SELECT * FROM updatenews where id=$del_id";
$rt = mysql_query ($sql,$con);
//print "$sql<br>";
$zip = new Ziplib();
while($nt=mysql_fetch_array($rt)){
//header '$nt[filename]<br>';
//header "$nt[content]";    // name class and mark will be printed with one line break at the end
//header ("Content-type: Content-Type: application/msword; charset=ISO-8859-1<br>");
//header ("Content-Disposition: attachment; filename=\"$nt[filename]\"<br>");
//header ("Content-length: $nt[size]<br>");
echo "<font face='chanakya' size='5' color='red'>$nt[content]</font><br><br>";
$files_to_zip = $nt[content];
$zip->zl_add_file($nt[content].$files_to_zip,$files_to_zip);

//$zip->close();
	//then send the headers to foce download the zip file
	header("Content-type: application/zip");
	header("Content-Disposition: attachment; filename=$archive_file_name");
	header("Pragma: no-cache");
	header("Expires: 0");
	readfile("$archive_file_name");
	exit;
//if true, good; if false, zip creation failed
//$result = create_zip($files_to_zip,'my-archive.zip');
}


						//echo "$content";
				//header('Location: _delete.php');
				}
				else
				{
				echo "Error: ".mysql_error();


}mysql_free_result($rt);
	mysql_close($con);
				}
	}





?><? ob_flush(); ?>

A "headers already sent" warning arises when a script tries to modify header data after sending content (for example using echo). When this content is sent, the server will send a standard set of headers followed by that content, so it cannot modify those headers any more (because it's now actually sending the html).

In you while loop you have:

#
echo "<font face='chanakya' size='5' color='red'>$nt[content]</font><br><br>";
#
$files_to_zip = $nt[content];
#
$zip->zl_add_file($nt[content].$files_to_zip,$files_to_zip);
#
 
#
//$zip->close();
#
//then send the headers to foce download the zip file
#
header("Content-type: application/zip");

- Notice you are trying to modify a http header after using echo.

If you post the line number of the error we can confirm that. Hope this helps :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.