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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:31:10+00:00 2026-06-09T05:31:10+00:00

I would like some help with my code. I’ve already searched answered questions on

  • 0

I would like some help with my code. I’ve already searched answered questions on this site but haven’t found anything that works unfortunately. I’m doing a website where you can write, save, delete and update notes. Now I’m trying to fix an update button were you can change a posted note using its unique ID. The update button is on a separate page from the notes, and you choose the ID of posted notes using using a drop-down menu showing the existing IDs in my database table. You choose it, write a new note and then click update.

This is my current code:

        <li id="id_number"><label>ID number: <select name="id_number"> 
            <option value =" ">Select number</option> 
              <?php $query = "SELECT * FROM notes"; 
              $result2 = mysql_query($query); 
              while ($row = mysql_fetch_array($result2)) { 
                $id = $row ['id']; 
                $select = ""; 
                if ($id == $idID2) {
                    $select = "selected" ; 
                    } 
                ?><option <?php print $select ?> value="<?php print $id; ?>"><?php print "$id";     
                ?></option><?php 
                }  
                ?>
          </select> 
          </label></li>
        <li id="note">New note:</li>
        <li id="note"> <textarea rows="10" cols="30" name="note" value="<?php print $note;?>"/></textarea></li>
        <li id="send"><input type="submit" name="submit" value="Update!"/></li>
    </ul>
    </form>

    <?php
        $id= $_POST ['id'];
        $subject= $_POST ['subject'];
        $note= $_POST ['note'];
    ?>

    <?php
    if (isset($_POST['submit'])) {  //validates the data
            $error="0";


            if ( $note == "" ) { 
                        $error++; 
                        $wrong .= "<p> You forgot to write a new note.</p>";
            }


        if ($error > 0) {
            print "<p><strong>You have made these errors:</strong></p>";
            ?>
                <?php print $wrong; ?>


            <?php
        }


    //if no errors  

        else { 
                $note = mysql_real_escape_string($note); 
                $note = htmlspecialchars($note);
                $id = mysql_real_escape_string($id); 
                $id = htmlspecialchars($id);
                $date = date("j/n, Y, H:i");
                $query = ("UPDATE notes SET note='$note' WHERE id='$id'");
                $result = mysql_query($query) or die (mysql_error()); 
                if ($result) { 
                print "<p>Note updated!</p>";
            }
        }   
    }

    ?>

When choosing an existing ID and change the note and clicking update it says “Note updated” but the note in the database remains the same.
What am i doing wrong?

  • 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-09T05:31:11+00:00Added an answer on June 9, 2026 at 5:31 am
    $id = $_POST['id']
    

    should be

    $id = $_POST['id_number']
    

    As far as I can tell, you aren’t referring to any input with name “id”.

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

Sidebar

Related Questions

I would like to ask some help. This is not homework but it is
I'm new to the site. would like some help if at all possible. I
I need some help figuring out how I should do this. I would like
im relatively new to ROR, and would like some help with the following code.
I would like to get some help to sort out the code I've come
I've encountered this interview question and would like some help in trying to understand
I would like some help in continuing my code using openCV library in order
Lots of questions similar but I have a specific example I would like some
I would like some help about an Android Application. I used the new Google
I would like some help parsing a dynamic (folder.subfolders) xml with xslt, I tried

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.