can someone help me - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

can someone help me

epolmuseepolmuse Posts: 1Member
<?
include("../db.php");
?>

Untitled Document






<?
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_courses=$_GET[id_courses]");
}
?>



<?
$bil=0;
$sql = "SELECT * FROM tbl_courses";
$result = mysql_query($sql);

while($rows = mysql_fetch_array($result))
{
if($bil%5==0)
{
print("<tr>");
}
$bil++;
?>
"><? echo $rows['courses'];?>(
<?
$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)'];
}

?>
)
<?
if($bil==5)
{
print("</tr>");
$bil=0;
}

}
?>
Category Of Upload


<?
if($_GET[id_courses]==NULL){
echo NULL;
}else{
?>





<?
$num = 1;
$sql = "SELECT * FROM tbl_upload WHERE id_courses='".$_GET[id_courses]."'";
$result = mysql_query($sql);

while($rows = mysql_fetch_array($result)){
?>





<? } ?>
No File Name Action
<? echo $num++; ?> <? echo $rows['$file_name']; ?> &id_upload=<? echo $rows['id_upload']; ?>">Delete
<? } ?>



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?

Comments

  • tvientitvienti Posts: 230Member
    : <?
    : include("../db.php");
    : ?>
    :
    : Untitled Document
    :
    :
    :
    :
    :
    :
    : <?
    : 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]");
    : }
    : ?>
    :
    :
    :
    :
    : <?
    : $bil=0;
    : $sql = "SELECT * FROM tbl_courses";
    : $result = mysql_query($sql);
    :
    : while($rows = mysql_fetch_array($result))
    : {
    : if($bil%5==0)
    : {
    : print("<tr>");
    : }
    : $bil++;
    : ?>
    : "><? echo $rows['courses'];?>(
    : <?
    : $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)'];
    : }
    :
    : ?>
    : )
    : <?
    : if($bil==5)
    : {
    : print("</tr>");
    : $bil=0;
    : }
    :
    : }
    : ?>
    :
    Category Of
    : Upload


    : <?
    : if($_GET[id_courses]==NULL){
    : echo NULL;
    : }else{
    : ?>
    :
    :
    :
    :
    :
    :
    : <?
    : $num = 1;
    : $sql = "SELECT * FROM tbl_upload WHERE
    : id_courses='".$_GET[id_courses]."'";
    : $result = mysql_query($sql);
    :
    : while($rows = mysql_fetch_array($result)){
    : ?>
    :
    :
    :
    :
    :
    : <? } ?>
    :
    NoFile NameAction
    <? echo $num++; ?><? echo $rows['$file_name']; ?>&id_upload=<? echo $rows['id_upload'];
    : ?>">Delete
    : <? } ?>
    :
    :
    :
    : 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:

    [code]
    $do = unlink('/path/to/file');
    if ($do === TRUE)
    echo 'Success! :D';
    else
    echo 'Failure :(';
    [/code]
Sign In or Register to comment.