# PHP Unlink

**URL:** <https://forum.kirupa.com/t/php-unlink/256932>\
**Category:** programming\
**Created:** [April 8, 2008, 10:39pm UTC](https://forum.kirupa.com/t/php-unlink/256932 "2008-04-08T22:39:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy03992](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Andy03992](https://forum.kirupa.com/u/Andy03992)\
**Post date:** [April 8, 2008, 10:39pm UTC](https://forum.kirupa.com/t/php-unlink/256932/1 "2008-04-08T22:39:03Z")

</div>

Hi - I’m quite new to PHP (and this is my first post)

I wanted to know why this doesn’t work:  
I’m getting variables from the URL:  
/Operation.php?file=Data.txt&op=delete

(Data.txt is in the same directory)

This is my code:

```php
$file2 = $_GET['file'];
$op2 = $_GET['op'];

function deletefile()
  {
 unlink($file2);
  }
  
  if ($op2 = "delete")
  {
 echo $file2;
 deletefile();
  }

```

And this is the error I get:  
**Warning** : unlink(): No such file or directory in **/home/…/Singh/Operation.php** on line \*\*15

\*\*The echo $file2 produces Data.txt  
What’s my problem? :puzzled:
