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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't delete link in database table

    Hi, I am trying to help a friend whose PHP programmer went AWOL. Only I know very little about PHP myself. He has, on the backend of his site, a piece of functionality that allows a user to upload a file which will be linked to from the home page of the website. The code I want to implement is as follows:

    <a href="news.php?acc=8&id=<?echo $data->id;?>">Delete File</a>, which goes into the MySQL database and clears out the information in the "file" column of the database table.

    This link passes information on to a file called modules/class_news.php, which has several scenarios set up. I have no idea what any of them do, but I set up an eighth scenario, as follows:

    case 8:
    # Erase news
    // el archivo viejo lo borramos
    mysql_connect($dbhost,$usuario,$clave);

    // erase the registry
    mysql_db_query($dbname,"update db_news set `file` = '' where id = $id ");
    mysql_db_query($dbname,$sql);

    $url = "../news.php?acc=8";
    Header("Location: $url");
    break;


    The error I am getting is as follows:

    Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site48/fst/var/www/html/controlpanel/modules/class_news.php:130) in /home/virtual/site48/fst/var/www/html/controlpanel/modules/class_news.php on line 150


    Anybody know an easy way to do this? Thanks! E-mail me if you can help at mike@kaptivate.com

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    That error specifies that your Header function is killing the script. This is because there is previous output to the browser prior to the sending of the header function. Unfortunatly, this can be cause by either this script or another which includes this script.
    In any case, your queries are also incorrect, mysql_query takes in a string and a resource identifier. You will need to pass the $dbname (assuming its the name of the database to use) into a mysql_select_db, and use the resource from the connected mysql_connect in the mysql_query("SELECT ...", $resourceID). You don't even need the resource though, since it was defined within the same script.
    I assume as well that the # sign is not really in there, but was written so we can read it correct? # is not a comment block in php, so that would have killed your script before the header.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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