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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:37:39+00:00 2026-06-05T12:37:39+00:00

I have a php page that needs to write to a database sometimes at

  • 0

I have a php page that needs to write to a database sometimes at the beginning of the script.

During a scheduled mysqldump backup, the page isn’t accessible, because it is trying to write to a table that is locked.

During the lock, MySql queues those sql updates, and after the backup is complete, they do get executed as desired. Yet my php page won’t display until the backup is complete.

However, since the updates do not return anything to the script, I wish they wouldn’t hang up my script during the lock; I hope there’s a way I can tell php to just send the sql update to mysql and don’t worry about confirmation that the update completed.

I want php to send the query to mysql, and then just continue on to the next line of php if the update doesn’t complete in one second.

I’m running php on a windows server, so I understand that some type of threading is not an option.

If there is way to set a timeout on that query (specifically), that might be ideal, but I don’t want to renege the sql update altogether if it times out. I still want MySQL to process it after the lock is gone.

What would you recommend (given that removing the sql updates altogether is not an option)?

  • 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-05T12:37:42+00:00Added an answer on June 5, 2026 at 12:37 pm

    For others that may come across this thread, I ultimately wrote this function to detect if the table is locked, and only do the SQL updates if it is NOT locked:

    function isLocked($databaseName,$tableName)
        {
            $sql = "show open tables from `".$databaseName."` where `table`=`".tableName."` and In_use > 0;";
            $result = @mysql_query($sql);
            if (mysql_num_rows($result) != 0 )
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    

    (note: This function assumes the database connection is already established)

    This works, because I’ve modified the code so that the sql updates will ultimately get done the next time the page is loaded without a lock in place.

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

Sidebar

Related Questions

I have a simple php page that displays data from a mysql database. I
I have a particular PHP page that, for various reasons, needs to save ~200
I have a page that I need to design in PhP/Html/Java/CSS that has to
I have a php page that contains a form with information I post to
I have a PHP page that returns a piece of HTML to set the
I have a PHP page that I run every minute through a CRON job.
I have a PHP page that does a couple of different things depending on
I have a php page that takes in a bunch of url parameters and
I have a PHP page that queries a DB to populate a form for
My requirement is that i have a .php page that has to display some

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.