: <?
: include("../db.php");
: ?><html>
: <head>
: <title>Untitled Document</title>
: <meta http-equiv="Content-Type" content="text/html;
: charset=iso-8859-1">
: <link href="../forAll.css" rel="stylesheet" type="text/css">
:
: </head>
:
: <body>
: <?
: include("upload_courses.php");
:
:
: if($_GET[pro]=="del"){
: $sql = "DELETE FROM tbl_upload WHERE id_upload='$_GET[id_upload]'";
: $result = mysql_query($sql);
:
: chdir('http://localhost/epol/admin/upload');
: $do = unlink($_GET[file_name]);
: if($do=="1"){
: echo "The file was deleted successfully.";
: } else
: { echo "There was an error trying to delete the file."; }
:
: header("location:module.php?module=upload&op=upload_courses&id_cour
: ses=$_GET[id_courses]");
: }
: ?>
: <table width="100%" border="0" cellspacing="0" cellpadding="0">
: <tr>
: <td class="forMenu"><div align="center">Category Of
: Upload</div><br></td>
: </tr>
: <?
: $bil=0;
: $sql = "SELECT * FROM tbl_courses";
: $result = mysql_query($sql);
:
: while($rows = mysql_fetch_array($result))
: {
: if($bil%5==0)
: {
: print("<tr>");
: }
: $bil++;
: ?>
: <td class="forTexts"><a
: href="module.php?module=upload&op=upload_courses&id_courses=<? echo
: $rows['id_courses'];?>"><? echo $rows['courses'];?></a>(
: <?
: $id_courses = $rows['id_courses'];
: $count = "SELECT COUNT(id_courses) FROM tbl_upload WHERE
: id_courses='".$id_courses."'";
: $exec = mysql_query($count);
:
: while($row = mysql_fetch_array($exec)){
: echo $row['COUNT(id_courses)'];
: }
:
: ?>
: )</td>
: <?
: if($bil==5)
: {
: print("</tr>");
: $bil=0;
: }
:
: }
: ?>
: </table><br><br>
: <?
: if($_GET[id_courses]==NULL){
: echo NULL;
: }else{
: ?>
: <table width="100%" border="0" cellpadding="0" cellspacing="2"
: class="forTexts">
: <tr>
: <td width="2%" bgcolor="#c1cede"><strong>No</strong></td>
: <td width="80%" bgcolor="#c1cede"><strong>File Name</strong></td>
: <td width="18%" bgcolor="#c1cede"><strong>Action</strong></td>
: </tr>
: <?
: $num = 1;
: $sql = "SELECT * FROM tbl_upload WHERE
: id_courses='".$_GET[id_courses]."'";
: $result = mysql_query($sql);
:
: while($rows = mysql_fetch_array($result)){
: ?>
: <tr>
: <td bgcolor="#58a9fb"><? echo $num++; ?></td>
: <td bgcolor="#58a9fb"><? echo $rows['$file_name']; ?></td>
: <td bgcolor="#58a9fb"><a onCLick="return confirm('Are you SURE
: you want to delete this record?')"
: href="module.php?module=upload&op=upload_courses&pro=del&id_courses=<
: ? echo $_GET[id_courses]; ?>&id_upload=<? echo $rows['id_upload'];
: ?>">Delete</a></td>
: </tr>
: <? } ?>
: </table>
: <? } ?>
: </body>
: </html>
:
: can someone help me, right now im trying to delete the file that has
: been uploaded...when i delete right now the in the database the file
: has been deleted but in the upload folder, the file still hasn't
: been deleted...can anyone help me?
Can you give us more information? Your code seems to include error checks that tell you if the file was deleted or not... what's it saying? Your error checking is looking for "1" to be returned from unlink in a success case, but unlink returns true or false. Not sure how PHP will compare "1" and true, but you should always use typed comparisons when possible, and this is a good place to do it. For example:
$do = unlink('/path/to/file');
if ($do === TRUE)
echo 'Success! :D';
else
echo 'Failure :(';