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

  • Home
  • SEARCH
  • 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 7936527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:14:40+00:00 2026-06-03T22:14:40+00:00

I want to delete a database row which contains a file name when the

  • 0

I want to delete a database row which contains a file name when the user clicks on cancel button. Problem is that it is not deleting the database row. What am I doing wrong that the database row is not being cancelled?

Below is the relevant code of the form:

var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" + 
  "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + 
  "<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" +     
  "</p><p class='imagef1_cancel' align='center'><label>" + 
  "<input type='button' name='imageCancel' class='imageCancel' value='Cancel' /></label>" +
  "<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>");

Below is the startImageUpload() function where it starts an file upload and where the cancel button function is stored:

  function startImageUpload(imageuploadform, imagefilename){
    $('.imagef1_cancel').eq(window.lastUploadImageIndex).find(".imageCancel").on("click", function(event) {
      return stopImageUpload(2);
      });     
    return true;
  }

Below is the stopImageUpload() function where it displays the cancel message using success and result:

function stopImageUpload(success, imagefilename){
  var result = '';
  if (success == 2){
    result = '<span class="imagecemsg"> The file upload was canceled!</span><br/><br/>';
  } else {
    result = '<span class="imageemsg">There was an error during file upload!</span><br/><br/>';
  }         
  return true;   
}

Finally below is the imageupload.php script which is linked to the QandATable.php (The script which contains the code above) using iframe and this is where the database row is suppose to be deleted from:

<?php
  session_start();
  ...//connected to DB
  $result = 0;

  if ($result == 2) {
    $imagecancelsql = "DELETE FROM Image 
                       WHERE ImageFile = 'ImageFiles/".
                       mysql_real_escape_string($_FILES['fileImage']['name'])."'";
    mysql_query($imagecancelsql);
  }
  mysql_close();
?>
<script language="javascript" type="text/javascript">window.top.stopImageUpload(<?php echo $result ? 'true' : 'false'; ?>, '<?php echo $_FILES['fileImage']['name'] ?>');</script>
  • 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-03T22:14:41+00:00Added an answer on June 3, 2026 at 10:14 pm

    In imageupload.php You declared:

    $result = 0;
    

    Then you say:

    if ($result == 2)...
    

    $result is 0 not 2 so the query will not be executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a grid-view, which contains an asp image-button for deleting row, i want
I have a table in my database which has duplicate records that I want
I want to delete a row from the database. I added the row to
I want to delete several row mysql database together after select with checkbox in
I want to delete a row from gridview and database - I write some
I have a cancel button where the user can cancel on a file upload
I have a problem when the user has clicked on the Cancel button. When
I have database application, I want to allow the user to restore the deleted
I want to delete a range of data from a text file using PHP.
I want to delete a row in the grid, but the grid always post's

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.