![]() |
Help with something that should be obvious...
Hi guys, I'm having one of those moments where I'm so deep in code that I can't work out what should be obvious in this case.
The following is a bit of PHP code which executes a certain function depending on if the timestamp $userlastsync is less than 1 or 2 weeks ago. I've set $warn_time to 10 minutes for debugging purposes because it appears to be executing both functions for no apparent reason. Both $userlastsync and $warn_time are returned as Unix timestamps. PHP Code:
It looks right to me, that's the problem. Because I've set the warn level to -10 minutes it should only be executing do_warn() based on the time given in the image in my sig. :help: |
Re: Help with something that should be obvious...
Quote:
Bit bizarre..... This is my test code in full, and it seems to work fine... PHP Code:
I basically just pasted your code in, changed the functions to echos and set the userlastsync myself. I can only think your problem must lie outside that |
Re: Help with something that should be obvious...
I would expect that the else precludes do_warn() from being executed - it acts as an XOR. I.e. either do_alert() or do_warn() will be executed but not both. I can't remember if PHP treats it this way though. I would also check on the comparision - is the interpretor actually comparing time or is it comparing strings, integers, or something else?
|
Re: Help with something that should be obvious...
No it is time strings.
I think it may actually be working correctly now, I just probably confused myself when I was coding it because the warning/alert functions send mail so I was receiving email for both that had been delayed for a while. |
Re: Help with something that should be obvious...
Quote:
I miss programming :( |
Re: Help with something that should be obvious...
I'm actually quite pleased with this system, it's working exactly as I wanted it to.
Only up to 633 lines of code though, I expect this to at least double before I'm finished. :D More info: http://richard.phpfuture.net:8080/co...y?user=richard |
| All times are GMT. The time now is 03:23. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum