View Full Version : Issues with headers

08-25-2009, 06:06 PM
I am working on a script to delete photos from a gallery. Basically submit a form to delete.php which grabs the id from the query string and runs the script. Here is delete.php


require 'database.php';

$id = $_POST['id'];

$q = "DELETE from gallery WHERE id = $id";

$result = $mysqli->query($q) or die("There was a problem!");

if($result) header("location: index.php");


Which when submitted gives me:

Warning: Cannot modify header information - headers already sent by (output started at /nfs/c04/h03/mnt/66004/domains/trifitla.com/html/g_b/database.php:1) in /nfs/c04/h03/mnt/66004/domains/trifitla.com/html/g_b/delete.php on line 11

for reference here is database.php:


$db_name = "photo_gallery";
$db_server = "localhost";
$db_user = "username";
$db_pass = "password";

$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error());


Any help is appreciated.

08-25-2009, 06:15 PM
Your file database.php either has some characters in the file before the <?php tag or the file was saved as Unicode/UTF-8 and you have BOM (Byte Order Mark) characters that your editor placed at the start of the file.

Make sure there is nothing in the file before the <?php tag and make sure your file is saved as an ANSI/ASCII file.

08-25-2009, 06:37 PM
Thanks @CFMaBiSmAd for the tip. I just copied code, deleted the old database.php, created a new one and saved it with the same code. Worked great. Thanks.

I do have one other question for you. Is there a application that let's me load my server logs into and make it more readable and quickly find specific details? Or what is the best way to read logs?