• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Duplicate counter number

Duplicate counter number 12 years 5 months ago #20098

Hi, I use this code to add a submission counter:

The counter code is:

//<code>
$db=JFactory::getDBO();
$db->setQuery("SELECT COUNT(`SubmissionId`) cnt FROM #__rsform_submissions WHERE FormId=2");
$db->query();
$result=$db->loadResult();
return intval($result)+1;
//</code>


However, the result is sometimes the same for 2 or more subsequent submissions (i.e. two submissions with the same counter value). I notice that is happening when submissions were sent close in time (< 5 or 10 min).

Is it related to cache? Is it related to server setting?

Thanks for helping me.
The administrator has disabled public write access.

Duplicate counter number 11 years 4 months ago #25775

  • info6356
  • info6356's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
i have the same problem, did you find a solution?
thx
The administrator has disabled public write access.

Duplicate counter number 11 years 4 months ago #25851

Hi

Are you running this code on form load or form submit (I don't recall the RSJoomla terms for these eventgs at the moment)? If the code runs at form load, you can very easily get duplicate numbers when the site is being used concurrently. For example, if I open the form, I get a form counter of COUNT + 1. While I'm filling out the form, you open the form. As I haven't submitted my form yet, the number of entries in the database hasn't changed. So your form also gets the same form counter of COUNT + 1. The result when we save is that we both save the same counter.

It would be better to determine the counter value when the form is saved. It is less likely that two users will submit the form at exactly the same moment, so it is more likely that we will get unique counter ids.

If you are running the code at form submit, please ignore my above wanderings :whistle:

Ta ra 'wan

Cymdeithas Madog
The administrator has disabled public write access.

Duplicate counter number 11 years 4 months ago #25856

  • upbm
  • upbm's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 34
  • Thank you received: 4
The administrator has disabled public write access.

Duplicate counter number 9 years 10 months ago #31556

  • info6356
  • info6356's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Hi i have similar problem and tried your code but i have a problem...

i used to have:
$db=JFactory::getDBO();
$db->setQuery("SELECT COUNT(`SubmissionId`) cnt FROM #__rsform_submissions WHERE FormId=5");
$db->query();
$result=$db->loadResult();
return intval($result)+1;

now i delete all that and typed:
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId='".(int) $formId."'");
$_POST = $db->loadResult()+1;

My question is:
i used to send a thank you email saying:
Thanks for your submission your registration number is {counter:value}

Now with the new code this doesn't work, the value shows blank on the email.
How can i fix this?

also
where in the code do i type the form ID number 5 like i did before? or i don't need this anymore?

thx
The administrator has disabled public write access.

Duplicate counter number 9 years 10 months ago #31563

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can try this:
//<code>
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId='".(int) $formId."'");
$result = $db->loadResult()+1;
return $result;
//</code>
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Duplicate counter number 9 years 10 months ago #31569

  • info6356
  • info6356's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
hi

with your code the {counter:value} is always 1.
The message is always showing the same number 1 and is not increasing to 2, 3, 4, 5...etc
:-(
The administrator has disabled public write access.

Duplicate counter number 9 years 10 months ago #31582

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
//<code>
// Get a database connection.
$db = JFactory::getDbo();
 
// Setup the query.
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `FormId`='1'");
$submissions = $db->loadResult() + 1;
 
return $submissions;
//</code>

It seems that the $formId variable is not available in the "default value" area of the field. You will need to add the actual Id of the form as per the example above (change 1 to the actual ID)
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!