Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-15-2007, 11:46 PM #1
- Join Date
- Mar 2007
- 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:
# 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";
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 email@example.com
03-16-2007, 12:04 AM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- 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.
header('HTTP/1.1 420 Enhance Your Calm');