Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts

    Question Issues with headers

    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

    PHP Code:
    <?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(
    $resultheader("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:
    PHP Code:
    <?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.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,028
    Thanks
    2
    Thanked 315 Times in 307 Posts
    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.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts
    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?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •