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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:08:46+00:00 2026-06-06T11:08:46+00:00

Using the following code: if (isset($_POST[‘delete’]) && isset($_POST[‘id’])) { $first = get_post(‘first’); $query =

  • 0

Using the following code:

if (isset($_POST['delete']) && isset($_POST['id']))
{
    $first = get_post('first');
    $query = "DELETE FROM user_master WHERE id='$id'";
    if(!mysql_query($query, $db_server))
        echo "DELETE failed: $query<br />" . 
        mysql_error() . "<br /><br />";
}

$query="SELECT * FROM user_master";
$result= mysql_query($query);

if(!result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);

for ($j=0 ; $j<$rows ; ++$j)
{
    $row = mysql_fetch_row($result);
    echo <<<_END
    <pre>
    ID      $row[0]
    First   $row[1]
    Last    $row[2]
    Email   $row[3]
    User    $row[4]
    </pre>
    <form action="willingLog.html" method="post">
    <input type="hidden" name="delete" value="yes" />
    <input type="hidden" name="id" value="$row[0]" />
    <input type="submit" value="DELETE RECORD" /></form>
_END;

I’m unable to delete a record form the table.

All the records form the table are printing on the screen, including the “DELETE RECORD” button. When I hit the button, however, nothing happens. I’ve checked the actual table on phpmyadmin, and the table is unaffected as well.

I’m pulling this stuff from a book, so I don’t understand why it’s not working.

  • 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-06T11:08:48+00:00Added an answer on June 6, 2026 at 11:08 am

    I do not see where you set the $id variable.

    if (isset($_POST['delete']) && isset($_POST['id']))
    {
        //$first = get_post('first');   #not sure what this does
        $id = sanitize($_POST['id'], 'int');  //protect from sql injection
        $query = "DELETE FROM user_master WHERE id=$id";
        if(!mysql_query($query, $db_server))
            echo "DELETE failed: $query<br />" . 
            mysql_error() . "<br /><br />";
    }
    

    Please be sure to sanitize any data sent across the network, i.e. $_POST. Also, if id is of a number type, do not surround the value in quotes or mysql will interpret it as a string.

    Lastly, look into using MySqli or PDO, as MySql API has been deprecated.

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

Sidebar

Related Questions

I'm using following code but cannot return data from MySQL. This is the output:
I have the following code: <select name=to class=combo value=' <?php if(isset($_POST['reply'])) { echo <option
<?php if (isset($_POST['first']) && isset($_POST['second']) && isset($_POST['submit']) && $_POST['DDL'] == "+") { $equals =
I am using following code, copied from a website, for a contact page. But
I have code similar to the following: $data['someField'] = (isset($_POST['someField'])) ? 'Y' : 'N';
Using following code I try to get updated list of checkbuttons' corresponding text values,
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,
I am using following code to check whether a check box on my website
I am using following code to design my home page. The output (as shown

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.