Topic awaiting preservation: Trouble in removing files from server |
|
---|---|
Author | Thread |
Nervous Wreck (II) Inmate From: Kansas, just this side of the rainbow |
posted 02-28-2006 20:59
I am creating an admin section on an intranet site. I need to remove files from a list that is on a database, so I am using the unlink() function. It works fine when I manually type the filename (i.e. remax.jpg) into the pathname. However, when I try and insert the variable from the database, it is completely ignored. The variable is working because it deletes the entry from the database. I have tried moving the function around thinking that it was a problem with my ordering of events, but no luck. Any suggestions would be appreciated. Code follows: code: $order_logo = "SELECT * FROM logo_table WHERE id = '$_POST[del_logo]' "; $get_logo = mysql_query($order_logo, $login) or die(mysql_error()); while ($row = mysql_fetch_row($get_logo)) { $id = $row['id']; $filename = $row['logo']; $name = $row['logo_name']; echo "$filename"; } //This will delete the file from the server. chmod( "logos/$filename, 777"); unlink( "logos/$filename"); //This will reset the rows that contain that logo in realestate_info_table to 'NONE'. $reset_logo = "UPDATE realestate_info_table SET logo = 'NONE' WHERE logo = '$filename' "; mysql_query($reset_logo) or die(mysql_error()); //This will delete the entry from logo_table. $delete_entry = "DELETE FROM logo_table WHERE id = '$_POST[del_logo]' "; mysql_query($delete_entry) or die(mysql_error());
|
Nervous Wreck (II) Inmate From: Kansas, just this side of the rainbow |
posted 02-28-2006 21:28
Okay, forgive my idiocy, I found my error. code: while ($row = mysql_fetch_row($get_logo)) { $id = $row['id']; $filename = $row['logo']; $name = $row['logo_name'];
code: while ($row = mysql_fetch_row($get_logo)) { $id = $row['0']; $filename = $row['1']; $name = $row['2'];
|