Deleting an image from the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jenn23
    New Member
    • Jul 2007
    • 3

    Deleting an image from the database

    Alright so I have this script that was written by the person that I replaced and I need some help.

    There is a trash can icon that when you click on it is supposed to delete an image. However....when I click on the icon, it sends me to a 404 Not Found page. (but the image is infact at its location)


    The end of the url that is linked to the icon says:

    /exh.img.del?f=e xh.image0529484 001178137571.jp g


    This is the code I've been looking at for "exh.img.del.php"
    and I just want to know if there is 'anything' at all wrong with this script:

    [code=php]
    <?

    $myFile = mysql_escape_st ring($_REQUEST['f']);
    $naa = $myFile;

    unlink($myFile) ;

    require('../../inc/baza.php');

    $link = mysql_connect($ host, $user, $pass, false, MYSQL_CLIENT_CO MPRESS);
    $alive = mysql_ping();

    if(!$alive) {
    echo "MySQL is not alive\n";
    } else {

    mysql_select_db ($dbName, $link) or die("Cant connect to database");
    $q = "DELETE FROM images WHERE imgStamp='$naa' ";
    $r = mysql_query($q) or die ("Couldnt execute query.");

    }

    $_SESSION['gTab'] = "tab5";
    $_SESSION['imgWhat'] = "add.new";
    $strana2 = "../../admin/admin.php?p=exh &pp=exh&goo=edi t.full";
    header("Locatio n: $strana2");



    ?>[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]
    Last edited by pbmods; Jul 18 '07, 06:56 PM. Reason: Added CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Jenn. Welcome to TSDN!

    Try changing the link from exh.img.del to exh.img.del.php .

    Comment

    • jenn23
      New Member
      • Jul 2007
      • 3

      #3
      Thanks so much!
      That worked :)
      I got other errors but atleast it actually deletes it now. yay.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

        Comment

        Working...