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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:00:46+00:00 2026-05-26T17:00:46+00:00

I have a form and a database table named reports . I have a

  • 0

I have a form and a database table named reports. I have a date field (primary key) and a textarea named changes to say what’s been changed on that date. If the date is the same I want to be able to overwrite the information in the ‘changes’ column for that date.

My insert command, which works on its own, is as follows:

mysql_query("
  INSERT INTO reports (thedate,changes)
    VALUES ('$_POST[thedate]','$_POST[changes]')
");

I understand that I’ll need to use ON DUPLICATE KEY UPDATE after my INSERT but after numerous attempts I cannot get it right. Not only do things no update but it seems to break my insert command so even a new row isn’t added to the database.

Apologies if this is a duplicate question. After lots of searching and lots of trying I cannot get it to work.

  • 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-05-26T17:00:47+00:00Added an answer on May 26, 2026 at 5:00 pm

    Have a look att REPLACE.

    REPLACE works exactly like INSERT, except that if an old row in the
    table has the same value as a new row for a PRIMARY KEY or a UNIQUE
    index, the old row is deleted before the new row is inserted.

    Note that if you have a foreign key with an action ON DELETE it will be triggered when using REPLACE since it does a delete followed by an insert .


    Using ON DUPLICATE KEY it could look like this:

    INSERT reports (thedate, changes) VALUES ('$_POST[thedate]', '$_POST[changes]')
      ON DUPLICATE KEY UPDATE changes = '$_POST[changes]'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that sends info into a database table. I have it
I have a database table named call with columns call_time, location, emergency_type and there
I have a table in database in which there is a column named roll_no,
I have a table in my database, named PriceRanges: PriceRanges ----------------- PriceRangeID (PK) RangeFrom
I have a MS Access database with few tables and a form. When more
i have a form that submits data to a database, i have a function
I have astring directly coming form the database and I am creating object of
I have a form that adds links to a database, deletes them, and --
I have a form that shows results from a database query, these results can
I have a form with a list that shows information from a database. I

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.