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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:49:07+00:00 2026-06-14T13:49:07+00:00

As shown here if there is a numeric id that matches $member_id that record

  • 0

As shown here if there is a numeric id that matches $member_id that record is deleted and $res evaluates to TRUE. If the table contains a ‘member_id’ that’s a string such as abc1234 it will only delete if I make $member_id a string by enclosing it in quotes ‘$member_id’ that will delete all matches but when then $res always evaluates to TRUE so if there is a mismatch nothing gets deleted(as it should) but the user gets a “$member_id.” has been removed from members table” message. I hope that was clear.

<?php 
$member_id = "";
require("connect.php");
if (isset($_POST['member_id']))$member_id = fix_string($_POST['member_id']);

$sql=("DELETE FROM members WHERE member_id = $member_id");
$res = mysqli_query($con,$sql);
**if($res) {
 echo "member with ID of ".$member_id." has been removed from members table";
} else {
    echo "member was not deleted";
}**

function fix_string($string) {
    if (get_magic_quotes_gpc()) $string = stripslashes($string);
    return htmlentities ($string);
}
?>
  • 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-14T13:49:09+00:00Added an answer on June 14, 2026 at 1:49 pm

    Your logic is in the right place, but not executed correctly. You’re trying to see if a user/member has been deleted by doing:

    $res = mysqli_query($con,$sql);
    if($res) {
    

    However, mysqli_query() will return true if the statement executed properly for a DELETE – it doesn’t matter if it deletes rows or not.

    What you’ll want to do is utilize mysqli::$affected_rows:

    $res = mysqli_query($con, $sql);
    if (mysqli_affected_rows($con) == 1) {
        echo "member with ID of ".$member_id." has been removed from members table";
    } else {
        echo "member was not deleted";
    }
    

    This will check if there was a single record affected by your DELETE statement (assuming your member-IDs are unique; if not, you could use >= 1 instead). If there was one, well, it was removed!

    Side Note (not answer specific)
    You should drop your fix_string() method and opt for mysqli‘s prepared statements which will auto-sanitize the input for you. You can try the following for your existing code:

    require("connect.php");
    $member_id = (!empty($_POST['member_id']) ? $_POST['member_id'] : '');
    
    // prepare the statement
    $stmt = mysqli_prepare($con, 'DELETE FROM members WHERE member_id = ?');
    
    // bind the id
    mysqli_stmt_bind_param($stmt, "s", $member_id);
    
    // execute the statement
    mysqli_stmt_execute($stmt);
    
    if (mysqli_affected_rows($con) == 1) {
        echo "member with ID of ".$member_id." has been removed from members table";
    } else {
        echo "member was not deleted";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a program that worked until recently. The offending code is shown here:
I have a table that contains several thousand rows, having a Varchar column that
There is an implementation shown here: http://msdn.microsoft.com/en-us/library/w369ty8x.aspx What's the advantages over just implementing this
I have a extension that uses multithreading using worker thread as shown here .
I am trying to parse the table shown here into a multi-dimensional php array.
I have a class that specifies a set of callback functions (shown here as
Is there a updated comparison according to the latest technologies offered as shown here
I have two tables as shown here . I am trying to fetch name
I need to give the countdown as shown here , for each item using
I wrote an an idle hook shown here void vApplicationIdleHook( void ) { asm(nop);

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.