premiso Posted February 11, 2009 Share Posted February 11, 2009 It dont show anything, all run normaly with delete mysql record and redirect on finish, just the files don't erase from server folder. Alright, lets comment out header(sprintf("Location: %s", $deleteGoTo)); Then re-run the script with the code I gave you. Let's see if anything is displayed. As the script I gave you would not "error out", although it should output something and cause a header error since it does echo information out no matter what. Given that, I do not think you updated the script properly on the site. Either it was uploaded to the wrong spot, or the wrong modified file was uploaded. As this should cause header errors since it outputs data before the header call. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759788 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 Something came out "The file does not exist!" I check table and pictures seem to be well stored ex: "images/etiquetas/ex002.jpg" next step??? Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759805 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Let's try this now: $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); echo 'The permissions for the file ' . $logonname . ' are: ' . $fileinfo . '<br />'; if (unlink($logoname)) { echo 'The file ' . $logoname . ' should be erased.<br />'; }else { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } And see what spits out. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759809 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 More info came out: "The permissions for the file are: 0715 The file /hsphere/local/home/dargil/dargil.pt/ was not erased." The folder are with permissions 777. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759813 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 The folder, maybe. The file is not. The file itself needs to be "writeable", which right now it is not, to be erased. $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } Give that a try and see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759817 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 Don't work !!! Message: "The file /hsphere/local/home/dargil/dargil.pt/ was not erased." Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759824 Share on other sites More sharing options...
andy_b42 Posted February 11, 2009 Share Posted February 11, 2009 Why is there a "/" after the filename? That will cause the machine to read dargil.pt as a folder and not a file. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759826 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 "The file /hsphere/local/home/dargil/dargil.pt/ was not erased." How come you have an ending / after dargil.pt ? Where is that coming from....well either way let's try this: $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . substr($row["logotipo"], 0, -1); if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } That should remove the ending slash. If the file actually does have that ending slash in it, then the issue is that. Files with ' and / tend to be very picky and can usually only manually be erased. I would suggest you filter your upload file names to remove or not allow those characters. Sorry I did not catch that earlier. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759827 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 the / is from a folder, files doesn't have / ' " or spaces. Full root from a file in server is for example: "/hsphere/local/home/dargil/dargil.pt/dargilmusica/images/etiquetas/ex002.jpg" Full root for internet is for example: "http://www.dargil.pt/dargilmusica/images/etiquetas/ex002.jpg" I give a try in last script and post the same: "The file /hsphere/local/home/dargil/dargil.pt/ was not erased." Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759837 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 It sounds like the data from the mysql DB is not coming out right cause $row["logotipo"] is empty. Verify that in MySQL it contains the data needed. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759847 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 Yes, database is ok The store data look like this: "images/etiquetas/ex002.jpg" Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759853 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Yes, database is ok The store data look like this: "images/etiquetas/ex002.jpg" I highly doubt that, at least on your remote server, try this and see what it spits out: echo 'The file name retrieved from the DB is: ' . $row["logotipo"] . " alternatively, if there is nothing there the DB column is either wrong, or there is no data for this row.<br />"; $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } If that is the case, figure out why you are not getting the correct information out of the DB, do you need to insert a test record, since this record should have been erased each time you ran the script previously? Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759860 Share on other sites More sharing options...
jomagi Posted February 11, 2009 Author Share Posted February 11, 2009 It show the next message: "The file name retrieved from the DB is: alternatively, if there is nothing there the DB column is either wrong, or there is no data for this row. The file /hsphere/local/home/dargil/dargil.pt/ was not erased." The database table in server (i made site with mysql in server, not local) is ok and update each time I insert or delete record, I check in MySQL Query Browser. In each new script I insert a new record (etiqueta) and then make the delete. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759875 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Well given that output, something is going wrong cause that value is incorrect. Is the column name "logotipo" ? Do some various checks, maybe even a print_r of the retrieved row from mysql to see what is being pulled out. Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-759876 Share on other sites More sharing options...
jomagi Posted February 12, 2009 Author Share Posted February 12, 2009 Thanks to all for the help. The problem are with the query. I have just "etiquetas" that is the table name, and after did a echo to the query realize that it doesn't find database, so just change to "dargil_site.etiquetas" and it work fine. So simple e so many time spend to guess, thanks to all, keep the good work! Quote Link to comment https://forums.phpfreaks.com/topic/144748-unlink/page/2/#findComment-760362 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.