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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:32:42+00:00 2026-05-16T16:32:42+00:00

Can the php function mysql_insert_id() return no result after processing the INSERT query in

  • 0

Can the php function mysql_insert_id() return no result after processing the INSERT query in mysql db?

Just to clarify. There was a script performing by cron on the production site. It contained a cycle for generating invoices for users. Each iteration consists of a INSERT db query and the mysql_insert_id() operation going right after the query – to fetch the generated invoice number. A set of iterations were performed without fetching the last inserted number.

Can it be caused by high db server load or by some other reasons that are not linked to the problem at the php code site?

Any help would be appreciated!

  • 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-16T16:32:43+00:00Added an answer on May 16, 2026 at 4:32 pm

    Offhand, I can think of a few cases where MySQL wouldn’t return the ID:

    • The table you’re inserting into doesn’t have an AUTO_INCREMENTed primary key.
    • You’re inserting multiple rows at once.
    • You’re calling mysql_insert_id() from a different connection than the INSERT query was executed.
    • The INSERT query didn’t succeed (for instance, it encountered a deadlock). Make sure you are checking the return value from mysql_query(), then use mysql_errno() and mysql_error().

    MySQL docs have a full list of conditions and details on how this function works.

    Of course, it’s also possible there is a bug in MySQL, which would depend on which version of MySQL you are using.

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

Sidebar

Related Questions

Is there a php function that someone can use to automatically detect if an
Is there a PHP function which can accept the image path of a PNG-24
I need a simple proxy PHP function/script that can download a file from a
How can I this PHP function include in jquery .html? PHP function: function trim_text($string,
It's clear from reading through threads that I can call a PHP function using
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {
I have a PHP function that requires can take 3 parameteres... I want to
I'm looking to create a PHP function that can trim each line in a
I can't make the following work. I know it's because of the PHP function
I would like to know how to create a php function that can be

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.