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 7922927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:08:16+00:00 2026-06-03T17:08:16+00:00

I have a Delete link listed beside all $rows , when I mouse over

  • 0

I have a Delete link listed beside all $rows, when I mouse over them they reflect the correct id for deletion, however, when I click DELETE I get redirected to phpfile.php?id=4, for example, and nothing is deleted, no errors are posted.

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC))
{
    echo '<tr><td align="left">' .
    $row['title'] . '</td><td align="left">'
    . $row['genre'] . '</td><td align="left">'
    . $row['length'] . '</td><td align="left">'
    . $row['created'] . '</td><td align="left">'
    . $row['views'] . '</td><td align="left">'
    . "<a href='newwriter_profile.php?id={$row['upload_id']}'>Delete</a></td>" .      '</tr>';
}
echo '</table>'; // Close the table

The remainder of the code, existing on the same page:

if(isset($_GET['id'])) {
// Get the ID
$id = intval($_GET['upload_id']);


require_once ('../mysqli_connect.php'); //Connect to the db




    $delquery = "
        DELETE 
        FROM upload
        WHERE upload_id = {$id}";
    $done = @mysqli_query ($dbc, $delquery); // Run the query

    if($done) {
        // Make sure the result is valid
        if (mysqli_num_rows($done)==1) {
        echo 'Record Deleted';
        }
        else {
            echo 'error - delete failed';
        }

        // Free the mysqli resources
        @mysqli_free_result($result);
    }
    else {
        echo "Error! Query failed:" .$mysqli_error($dbc);
    }
    mysqli_free_result($done);
    mysqli_close($dbc);
}

If I can solve this bug I will solve a similar bug except with a Download function.

  • 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-03T17:08:19+00:00Added an answer on June 3, 2026 at 5:08 pm

    You are pulling $id from the non-existent $_GET['upload_id'] when you intend to use $_GET['id']. Since $_GET['upload_id'] is not set, its value is NULL, which gets interpreted as 0. Your query ends up as: DELETE FROM upload WHERE upload_id = 0

    $id = intval($_GET['upload_id']);
    // Should be
    $id = intval($_GET['id']);
    

    Instead of using intval(), I would suggest using more extensive bounds checking on $id. If for example, a string like "abc" were passed in ?id=abc, intval("abc") would cast it to 0 and you would pass 0 into your query. If id needs to be a positive integer, use something like:

    if (ctype_digit($_GET['id'])) {
      // ok, do your query
    }
    else {
      // invalid input, report error to user and don't touch your database.
    }
    

    Finally, we don’t see the rest of your script, but it is usually crucial when using a hyperlink to perform a delete action (or any action for that matter) that you check ownership of the row you are attempting to delete before completing the action. Make sure that the logged-in user has permission to delete the row, and if not, don’t perform any database action. Otherwise, any user could pass any value into the URL to modify others’ data. Suggested reading: The Spider of Doom

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

Sidebar

Related Questions

I have to delete all rows of a model with condition fkey_id = 1
I want to have a delete user link in a normal Activerecord table, but
I have a GirdView table in my application. I have a Delete link button
I have simple delete link: = link_to Delete, messages_path(message.id), :method => :delete Gives me
I have HTML something like this: <table> <tr> <td><div class='record'>Record Link</div></td> <td><div class='delete' style='display:none;'>Delete
I have a delete file link on a page: <form id=myForm runat=server> <asp:LinkButton ID=deleteFileLink
I want to have a Delete-link on a page viewing an object in my
I have a link to delete action using Jquery dialog confirm message. Clicking on
I have a ListView and I have set up my Delete Link button. When
I have a list: <ul id=links_list class=links_list> <li id=296 class=sidebar_link>text <a onclick=deleteLink(296) href=javascript:void(0);>Delete Link</a>

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.