i dont know why i am having an error in header

Warning: Cannot modify header information - headers already sent by (output started at delete.php on line 13




	$id =$_REQUEST['BookID'];
	// sending query
	mysql_query("DELETE FROM books WHERE BookID = '$id'")
	or die(mysql_error());  	
	header("Location: index.php");



	$conn = mysql_connect('localhost', 'root', '');
	 if (!$conn)
	 die('Could not connect: ' . mysql_error());
	mysql_select_db("Books", $conn);


Recommended Answers

All 4 Replies

i have error in line 28


$id =$_REQUEST['BookID'];

$result = mysql_query("SELECT * FROM books WHERE BookID  = '$id'");
$test = mysql_fetch_array($result);
if (!$result)
		die("Error: Data not found..");
				$Title=$test['Title'] ;
				$Author= $test['Author'] ;					
				$PublisherName=$test['PublisherName'] ;
				$CopyrightYear=$test['CopyrightYear'] ;

	$title_save = $_POST['title'];
	$author_save = $_POST['author'];
	$name_save = $_POST['name'];
	$copy_save = $_POST['copy'];

	mysql_query("UPDATE books SET Title ='$title_save', Author ='$author_save',
		 PublisherName ='$name_save',CopyrightYear ='$copy_save' WHERE BookID = '$id'")
				or die(mysql_error()); 
	echo "Saved!";

	header("Location: index.php");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<form method="post">
		<td><input type="text" name="title" value="<?php echo $Title ?>"/></td>
		<td><input type="text" name="author" value="<?php echo $Author ?>"/></td>
		<td>Publisher Name</td>
		<td><input type="text" name="name" value="<?php echo $PublisherName ?>"/></td>
		<td>Copyright Year</td>
		<td><input type="text" name="copy" value="<?php echo $CopyrightYear ?>"/></td>
		<td><input type="submit" name="save" value="save" /></td>


i have an error in line 28.

Member Avatar

Obviously - you've echoed 'Saved'.

Re-read my last post.

use ob_start(); after the <?php at the very first php code and ob_flush(); before the the end tag ?>

Be a part of the DaniWeb community

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