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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:28:18+00:00 2026-06-07T20:28:18+00:00

Basically it look through the mp3 files in the folder and then insert into

  • 0

Basically it look through the mp3 files in the folder and then insert into mysql database if number does not exist.

Problem is INSERT (mysql) has been inserted more than 1 time but with different member_id‘s with same number. This shouldn’t happen.

4 staffs are executing this scripts. What causing this and how to fix?

if ($handle = opendir($audioPath)) {
    while (false !== ($entry = readdir($handle))) {
        $file = pathinfo($entry);
        if ($entry != "." && $entry != ".." && !is_dir($audioPath . "/" . $entry) && $file['extension'] == 'mp3') {
            $number = $file['filename'];
            $SQL = "SELECT mobile, status, member_id, count(*) as Total from result WHERE number = :number";
            $query = $this->db->prepare($SQL);
            $query->bindValue(":number", $number);
            $query->execute();

            $row = $query->fetch(PDO::FETCH_ASSOC);

            // Check if number is exist in the table
            if ($row['Total'] == 0) {
                $SQL = "INSERT INTO result (number, status, status_date, member_id) VALUES ('$number', 'pending', now(), '$memberId')";
                $queryInsert = $this->db->prepare($SQL);
                $queryInsert->execute();
                break;
            } 
        }
    }
}

after break it play mp3 via media player plugin.

  • 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-07T20:28:20+00:00Added an answer on June 7, 2026 at 8:28 pm

    You are probably running into a race condition where two people execute the script simultaneously. When the select is performed, the entry does not exist.

    The best way to solve this is to add a UNIQUE constraint on your number field in MySQL. This will make sure the condition is matched at insertion. The query will fail, so you will need to handle the error.

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

Sidebar

Related Questions

I've been trying to create a generic event. Basically it should look like this:
How can i change the look of the jqgrid without changeing the stylesheet. Basically
having another problem with my javascript for my table. Basically, if you look at
Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.
basically I want to validate whether or not a text box is a certain
I want to setup my WinForm to look like the Delphi7 IDE. Basically that
Hey there. Basically, I have a batch-file, that goes through all model and texture
I was just taking a look through the source for the examples on the
I'm having trouble thinking this through, but basically I want to create an Elixir
Well - the title basically says it. I want to look at the URLs

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.