Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:05:09+00:00 2026-06-03T05:05:09+00:00

What I am trying to do is that when the user clicks on the

  • 0

What I am trying to do is that when the user clicks on the “Delete” button, it deletes the file from the server and it removes the database row the same file name is stored in. Now the file deletes from the server successfully, that is not the problem.

The problem is that it is not deleting the database row where the same file name is stored in. How can I get it to achieve this?

Below is the javascript function of the delete button which navigates to the deleteimage.php:

var counter = 0;

function stopImageUpload(success, imagefilename){
    counter++;

    $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); 

    var _counter = counter;

    $('.listImage').eq(window.lastUploadImageIndex).find(".deletefileimage").on("click", function(event) {
        var image_file_name = $(this).attr('image_file_name');

        jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
            .done(function(data) {
                $(".imagemsg" + _counter).html(data);
            });

        $(this).parent().remove();
    });

    return true;   
}

Below is deleteimage.php:

<?php

$username="xxx";
$password="xxx";
$database="xxx";

mysql_connect('localhost',$username,$password);

mysql_select_db($database) or die( "Unable to select database");

$image_file_name = $_GET["imagefilename"];

echo "$image_file_name was Deleted";
unlink("ImageFiles/$image_file_name");

$imagedeletesql = "DELETE FROM Image (ImageFile) 
    WHERE ('ImageFile = ImageFiles/". mysql_real_escape_string($image_file_name)."')";

mysql_query($imagedeletesql);

mysql_close();

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:05:10+00:00Added an answer on June 3, 2026 at 5:05 am

    Looks like your SQL syntax is a bit off. Try this:

    $imagedeletesql = "DELETE FROM Image 
        WHERE ImageFile = 'ImageFiles/". mysql_real_escape_string($image_file_name)."'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a user that can only read from a database. This
I'm trying to get it so that when the user clicks popbtnnext within the
I'm trying to test an OpenFileDialog that is created when the user clicks on
I'm trying to write a application that sends user's geolocation to MYSQL database every
I'm trying to save the site that a user came from when they sign
I'm trying to save some information from a user that is saved on the
I'm trying to empty a textarea that is populated from a database with php.
I'm trying to refine a search list so that when a user clicks on
I'm trying to develop an app that prevents a user from getting to a
I am trying to make a PHP script that fetches records from the database,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.