View Full Version : Can't delete link in database table

03-16-2007, 12:46 AM
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

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

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

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

03-16-2007, 01:04 AM
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.