I'm having trouble deleting this file...
keep getting this error : Warning: unlink(Gate_pass.csv) [function.unlink]: Permission denied in C:\wamp\www\SVS\copydata.php on line 31

i search trough some sites, they said replace the $myFile with the orginal name Gate_pass.csv, but still getting the same error...can someone guide me on this matter. thank you

<?php
require_once 'connection_details.php';  //Calling the Connection Detail php file
$db_name="shipmenttracker";             // Database name
$tbl_name="serverdata";                 // Table name
$tbl_name1="maindata";                  // Table name
$tbl_name2="scandata";                  // Table name

//--Establishing connection to database
$dbh1=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die(mysql_error());

$myFile = "Gate_pass.csv";
$rows = file('Gate_pass.csv');
for($i = 1; $i < sizeof($rows); $i++) 
{
    list($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8) = explode(',', $rows[$i]);
    $shipping_no=($field2.$field5);
    $sql2="SELECT * FROM $tbl_name WHERE shipping_no='$shipping_no'";       //the sql query
    $result = mysql_query($sql2);
    $row=mysql_num_rows($result);
    if($row>0)
    {
        $sql3="Delete from $tbl_name where shipping_no='$shipping_no'";
        $result2 = mysql_query($sql3);
        $sql4="DELETE from $tbl_name1 where shipping_no='$shipping_no'";
        $result3 = mysql_query($sql4);
        $sql5="DELETE from $tbl_name2 where shipping_no='$shipping_no'";
        $result4 = mysql_query($sql5);
        $query1 = "Insert into $tbl_name values (' ','$field1', '$field2', '$field3', '$field4', '$field5', '$field6', '$field7', '$field8','$shipping_no')";
        mysql_query($query1);
        //unlink($myFile);
        unlink("Gate_pass.csv");

        //header("refresh:1;url=dataverification.php"); 
    }
    else
    {
        $query = "Insert into $tbl_name values (' ','$field1', '$field2', '$field3', '$field4', '$field5', '$field6', '$field7', '$field8','$shipping_no')";
        mysql_query($query);
        //unlink($myFile);
        unlink("Gate_pass.csv");
        //header("refresh:1;url=dataverification.php");
    }
}

?>

it works now....don't know why...sorry guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.