<?php
require 'header.php';
require 'connection.php';
mysql_query("DELETE FROM quotes WHERE ID = $_GET[id]") or die("didnt delete properly");
header('Location: index.php');
?>
When I run this it says:
Warning: Cannot modify header information – headers already sent by (output started at xxxxx on line 6
What is wrong?
Either
header.phporconnection.phpare outputting some content. You cannot modify the HTTP headers after content is sent, because the headers have already been sent at that point.A hack of a solution would be this:
However, you should instead figure out where content is being sent and suppress it, or reorder it to come after the
header()call.If, as I suspect,
header.phpoutputs an HTML header, you can just eliminate therequire 'header.php';line — the content will never be shown anyway, since this is a redirect.Also, note that the HTTP standard requires that the value of a Location header be an absolute URL. Therefore,
header('Location: index.php');will generate an HTTP response that is invalid according to the HTTP standard.