php help with unlink()

Discussion in 'Web Design and Development' started by italiano40, Jan 7, 2009.

  1. italiano40 macrumors 65816

    italiano40

    Joined:
    Oct 7, 2007
    Location:
    NY
    #1
    i trying to unlink to delete what i am doing wrong?

    Code:
    <?php
    ob_start();
    $code=$_REQUEST['deletecode'];
    $picturename=$_REQUEST['picturename'];
    $con = mysql_connect("localhost","USERNAME","PASSWORD");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
        mysql_select_db("DB", $con);
        $result = mysql_query("SELECT * FROM pictures
        WHERE code='$code'");
        $row = mysql_fetch_array($result);
    if (!unlink('pic/$picturename'))
      {
        header ('Location: index.php?u=false');
      }
    else
      {
      mysql_query("DELETE FROM pictures WHERE code=$code",$con);
        header ('Location: index.php?u=true');
      }
      mysql_close($con);
      ob_flush();
    ?>
    
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  3. italiano40 thread starter macrumors 65816

    italiano40

    Joined:
    Oct 7, 2007
    Location:
    NY

Share This Page