Marcus2000 Posted February 24, 2012 Share Posted February 24, 2012 Hi guys, I know this is a bit of a messy question, but i have a problem with some code that my friend wrote, and now i don't know how to fix it. Basically there is a line of code on my site, and what my friend told me was that this specific line of code has to do with the server and is similar to a ticking clock. What he told me is that it is a "counted related value" which needs to been changed every now and then when it hits the servers limit. This actually means nothing to me, but i'm hoping some one out there knows what my friend means. Anyway this is the line of code i need to change, or in fact the number i need to change. The problem is that as i dont really know what i'm doing i have no idea as to what to change the number to. Please help guys, I really need to fix this asap. Anyways this is the code: // unique references define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52330000000); // table id define ('SID', strtoupper(uniqid(''))); // short unique id define ('UID', strtoupper(md5(uniqid('')))); // 32char id Its the number 52330000000 that i had to change the last time i had this problem. Many thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/257669-how-to-get-a-counter-related-value-that-works-with-my-server/ Share on other sites More sharing options...
Marcus2000 Posted February 24, 2012 Author Share Posted February 24, 2012 Maybe this may help you guys out a bit. This is what my friend told me to do the last time I had this problem: REPLACE define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52230000000); // table id BY define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52330000000); // table id (52230000000 to 52330000000, 52330000000 BEING THE CORRECT VALUE, it’s a counter related value, and on some servers, the counter already reaches its limit with the initial figure) This did in fact work for about 3 or 4 weeks. But now I have the same problem, where my uses can't make any changes on their accounts on my website. Quote Link to comment https://forums.phpfreaks.com/topic/257669-how-to-get-a-counter-related-value-that-works-with-my-server/#findComment-1320672 Share on other sites More sharing options...
AyKay47 Posted February 24, 2012 Share Posted February 24, 2012 this has to do with the integer limit of PHP. I have ran the expression that you have provided and get an int of 2250700398. Since it is dependant on uniqid, this number is always incresing since it is based off of the current time in milliseconds which then gets converted with hexdec. I'm assuming that your platform is 32 bit otherwise you would not be having this issue. Basically what is happening is the number has reached its maximum integer limit and is being converted into type float, which apparently is a bad thing. I don't know the specifics here so it is hard to tell you exactly what you need to do. Making the subtracted number (52230000000) is on way of handling this, but it is inefficient as it will require you to change the number frequently. My thinking right now is that this is the only solution, as you could subtract an ever increasing number like (time() * 20), this would increase the time span that the number would remain valid, but you will still need to change it. Further reading: http://us2.php.net/manual/en/language.types.integer.php There is most likely a better way to do whatever it is that this does. Quote Link to comment https://forums.phpfreaks.com/topic/257669-how-to-get-a-counter-related-value-that-works-with-my-server/#findComment-1320810 Share on other sites More sharing options...
Marcus2000 Posted February 28, 2012 Author Share Posted February 28, 2012 Thanks for your much needed explanation AyKay47, The problem has been fixed since, however because of your good self I now have a much better understanding of the initial problem. Thanks for pointing me in the right direction. Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/257669-how-to-get-a-counter-related-value-that-works-with-my-server/#findComment-1321971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.