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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:59:40+00:00 2026-05-28T04:59:40+00:00

I am currently developing an auction website as part of a portfolio project and

  • 0

I am currently developing an auction website as part of a portfolio project and I have come across an interesting problem which can’t seem to resolve.

At the moment I am currently checking the current highest bid (query 1) and then if the bid is higher than the one currently stored then I am inserting the new bid into the database (query 2). Fairly basic logic, and obviously if the bid is lower then the user will eventually be notified.

Query 1:    

$result = mysql_query("SELECT * FROM bids WHERE item_id = '".$_POST['id']."' ORDER BY bids.amount DESC LIMIT 1");

Query 2:

    $query = sprintf("INSERT INTO bids(item_id,buyer_id,amount,created) VALUES('%s','%s','%s',NOW())",
                mysql_real_escape_string($item_id),     
                mysql_real_escape_string($user_id),     
                mysql_real_escape_string($amount));

Note: I know there are major security issues with this code but this is just an example…

However, I am uncertain if there will be a situation where between the gap of checking the price and inserting into the database, another query could infact go faster, insert into the database and then ruin the current bidding logic.

Will using transactions with the mysqli or PDO driver sufficient to ensure that the bids are queued correctly?

Does MySQL provide a method of queuing mysql queries to ensure that this will not happen?

  • 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-28T04:59:41+00:00Added an answer on May 28, 2026 at 4:59 am

    A possible way is to use a select for update, which if you disable the autocommit, lock the selected row. At this point, if the bid is higher, you insert the new bid and commit the transaction, if the bid is lower you can notify the user and rollback (or commit) the transaction

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

Sidebar

Related Questions

Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a penny auction website to test my ability at programming javascript
i m developing a dynamic website but i have a problem with a query.
I am currently developing a Chrome extension in which I have to get the
I'm currently developing a website. Every feature works fine. However, I'm using a lot
I am currently developing a private framework for use on WebKit devices. I have
Problem background I am currently developing a framework of Ant Colony System algorithms. I
I'm currently developing a application where I will have multiple windows open using C#
I am currently developing an online Auction system using ASP.NET 3.5 and SQLServer 2008.
I am currently developing Web Crawling in android I have a code to check

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.