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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:55:41+00:00 2026-06-10T21:55:41+00:00

Using PHP and MySQL I want to track sign ups using a PARENT and

  • 0

Using PHP and MySQL I want to track sign ups using a PARENT and multi-CHILD relationship.
A problem occurs if more than 1 user attempts to sign up using the same parent code. The parent will only be credited for 1 user and not 2.
The solution as I understand it is to LOCK the record. Or use the server time and the record timestamp to determine last update.

#THIS IS NOT PRODUCTION CODE, BUT JUST INTENDED TO DEFINE MY PROCESS
#PLEASE ADVISE AND MAKE ADJUSTMENTS AS YOU SEE FIT

$sqlget = SELCT * record of PARENT and WHERE id is of PARENT
$ts -> timestamp;
$st -> servertime;
$af -> aff_number;

NOW I WANT TO CHECK THE LAST RECORD UPDATE OF THE TIMESTAMP OF THE PARENT,
IF THAT UPDATE OCCURRED LESS THAN 10 SECONDS AGO – I WANT TO RERUN my $sqlget

How do i Convert $ts to an INT and $st to an INT so that I can run an IF statement
to loop $sqlget IF my condition fails.

if($ts <= $st by 10 seconds) { wait 10 seconds and rerun sqlget } 
else { get current $af (INT) and +1; UPDATE record; close connection; 
META-refresh to next page; }

So does this process seem functional? Will this ensure that a PARENT is always properly credited for each child signup even if more than 1 child signs simultaneously?
I don’t expect multi-concurrent signups, but they may occur on a occasion and i must ensure that the PARENT is properly credited.

  • 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-10T21:55:42+00:00Added an answer on June 10, 2026 at 9:55 pm

    I do not understand your SQL structure.

    If you associate a “credit” with the appearance of a new child with the same parent ID, then any number of users may affiliate simultaneously.

    Just run:

    INSERT INTO affiliations ( id_p, ... ) VALUES ( id_of_parent, whatever_data );
    

    and you’re done. It is indifferent whether parents and children are in separate tables or not. The important thing is that there must be no reference from the parent to the children, i.e., your only reference is the parent’s id in the child row. This way you have no concurrency problems on parent.

    When you need to know how many children a given parent has got, simply COUNT them:

    SELECT COUNT(*) FROM affiliations WHERE id_p = id_of_parent;

    I suspect that you are now storing a counter in the parent row. If it is so, don’t: it looks simpler, but the concurrency problems make it not worth the effort.

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

Sidebar

Related Questions

Using PHP and MySQL, I want to select only 6 rows from table which
I want to delete the most recent entry in MySQL using PHP, is there
i want to retrieve image stored in mysql as path using php and display
I am using php, js, flash and mysql on 1 website. I want to
I'm programming a script using PHP and MySQL and I want to get a
I am trying to make a full complex search using php and mysql.I want
I have been using php/mysql for a while now, I want to sanitize all
Hello I have a website. created using php,mysql. I want to set a limit
I am using PHP with MYSQL and want to add a feature to upload
I have a website I am building using PHP and mysql and want to

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.