Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Telling us the file name and line number where a problem happened does not help us. I posted a link. Read it and follow its instructions.
  2. Make sure you have your php.ini set up for development with these settings (restart WAMP if you change them): error_reporting = -1 display_errors = on Then look for error messages.
  3. http://www.catb.org/~esr/faqs/smart-questions.html
  4. I'm thinking either (a) the while loop Barand pointed out is returning more rows than expected or (b) the PHP script is executing twice. Both should be pretty easy to test.
  5. The other common reason for PHP trying to allocate absurd amounts of memory is, unfortunately, a PHP bug. Exactly which version are you using? Was it upgraded recently?
  6. Wouldn't it be easier to have the data on the page when it loads instead of having to load the page and then load even more after that?
  7. So... do that? You can tell what button is pressed, so if they pressed the Delete button then make the code do what you want it to do.
  8. You have it choose selectedIndex=0. It's not visible but that actually selects the first option - Select. If you want to unselect an option then set selectedIndex to -1.
  9. foreach($myObjectMap1 as $key => $item): $key is only valid for use on $myObjectMap1. Using it on Users $item->Users[$key] will not work correctly. Hint: if you have two arrays then you probably need two loops.
  10. It's the standard model of particle physics. You know, the one where everyone says it's too damn complicated and there's gotta be a simpler model of Everything. In other words, quantum bovine scatology.
  11. Let's see... So obviously you can't go polynomial for this. 21 data points means a 20th-order polynomial, and that's only 1 hour's worth of data. Also can't go sinusoidal because that's essentially a wavy line on top of a polynomial. You're getting into math that's beyond my capabilities. In essence, I think you need to fit a curve to a handful of points within a moving window (say, a window of 7 points and a best-fit 3rd-order polynomial) in a way that the curves smooth out. You're going to want a statistics library to do this.
  12. Oh, dude, that makes so much more sense to work with. Really should have started off with that. But first: you are combining rows and not columns, right? P49s get math-ed together, P51s, P55s, and P60s too, but you aren't mathing more than one of those together (as far as this thread is concerned), right? Seems to me you should first try to focus on merging those rows at creation time rather than later after the fact. Given that the sensors seem to poll every 3 minutes, how about the code storing this data first tries to UPDATE an existing row created within the last minute (and only INSERTs if not)? 13:00:22: P51 and P60 happen together, no rows within the last minute, create new row as [null, 4.47, null, 16.43] 13:00:25: P49 and P55 happen together, existing row within the last minute, update row to be [0.23, 4.47, 4.75, 16.43] 13:03:22: P51 and P60 happen, no rows within the last minute, create new row... That "one minute" can be any window you want as long as (a) it's consistently shorter than the time between every sensor's reports and (b) it's longer than the time between "sets" of sensor reports. If the window is too long and violates (a) then the data is still good but you're losing some values because newer ones are overwriting. If the window is too short and violates (b) then you get holes in your data, and though too many holes will break the chart, that's not likely to happen and besides it isn't a critical problem if it does. You do lose the timestamp of the second set of data, but you could fix that by also tracking timestamps of each sensor value reported. So that's five: creation time plus one for each sensor.
  13. They aren't even consistent with themselves. I would expect a sensor to report values on a regular basis, even if not at the same rate as another sensor, and yet, for the Value1 sensor, you have a value at midnight, one at 2:13, one at 3:14, and then nothing until 7:30? Too little data and all you can do is guess... Now, if you want to get really smart, you might be able to pool more data than you think. For example, if daily values tend to be similar then you can include the previous and next days' data in calculations. Expand out to a week or more both ways and you can derive a trendline for your trendline...
  14. Capital letters does not make it an environment variable. It it were then you would probably be using $_ENV instead of $_SERVER. https://www.php.net/manual/en/reserved.variables.server.php HTTP headers stored in $_SERVER are prefixed by "HTTP_". Take a look on that page to see if maybe there's something useful. To the question itself (since it is possible the User-Agent header may not be passed) then then solution is to check if the value is set before trying to use it.
  15. Yeah, looks like I was just being pedantic. Your question is "I have values measured inconsistently over time and I want to group similar values together and I'm currently doing some math on them". Raises questions like "what values?" and "why are they inconsistent?" and "does it make sense to group/average them like you've been doing, and if so why and how?" and "are you trying to interpolate data or render a chart or what?" And you can't tell it "no, these aren't discrete values, please give me a trendline"? Surely there's some sort of options to override what it's trying to determine automatically.
  16. Good that you solved it, but next time, it would be nice if you could let us know that the problem was the code thinking the radio button's value is "t" when the form uses "Active". In case someone else comes to this thread hoping for an answer to their own problems.
  17. If you don't want to display a thing, and by that I mean it doesn't even need to go on the page, then wouldn't it be best if you completely skipped outputting the HTML for that field entirely? Here's your code, slightly cleaned up and in such a way that points out how what you posted was incomplete: foreach($this->fDisplay[5] as $field) { $c = $this->field->showFieldValue($this->content,$field); if(($c !== "")&&($c !== null)) { $title = $this->field->showFieldTitle(@$this->content->catid,$field); echo "<span class='f".$field->name."'>"; if ($title != "") echo "<b>".htmlspecialchars($title)."</b>: "; echo "$c<br/>"; echo "</span>"; } I don't know what else is in the foreach loop - perhaps there's nothing else and the next line is the loop's closing brace - but odds are you can skip everything in that loop as soon as you realize it's trying to process the email field. continue lets you do exactly that. At the beginning of the loop, add an if statement that checks your criteria: it's the email field and the user is logged in. For its code, call continue; and... I think that should be all you need. If you have problems, post the code you came up with.
  18. 1. Are you sure $c is the field name? Are you sure the field name isn't in the conveniently-named $field variable? 2. Are you sure it has to be as complicated as "contains"? Surely the name of the field is "email"? Forget "remove". Try phrasing it a different way with different words.
  19. What's the code for your HTML form? Specifically for the radio buttons.
  20. Least squares does not come up with equations. It's meant for times when you have too much data and are trying to "average" it out to try to get an "actual" value, and from there you can easily derive an equation. By the way, to get a good equation you have to inject a little knowledge of your own into the system. Like whether the underlying truth is polynomial or sinusoidal in nature. In other words, to apply fun statistical models to your data, you are going to need a lot more data to work with. Tip: now would be a good time for the question to stop being abstract.
  21. Doesn't look valid to me. Like, the 00 hour has a single Value1 measurement of 37, but you're outputting 36.63? Shouldn't the value be, you know, 37? And the 10 hour has a Value2 measurement of 76, but now you're pushing that way up to 85.87?
  22. The simplest SQL solution would be to average everything and GROUP BY the hour (which you can do by formatting the date to Y-m-d H:i:00). Not sure averaging is right, though. If you need something more complex then you might want to shift all the processing to PHP and go with some statistical-type analysis. Dunno. Depends on what the measurements and timestamps mean.
  23. Great. So... problem solved?
  24. In other words, "if the field is email && the user is logged in || the field is not the email" then show it?
  25. If those two objects weren't being used anywhere else, and really were eligible to be cleaned up if not for the fact that they referenced each other, then gc_collect_cycles() is an option. However it's a relatively expensive operation (it goes through the symbol tables looking for circular references that could be cleaned up) so it's the sort of thing you should avoid needing to use - avoiding in ways such as altering the code a tiny bit to break the circle when you're done with the object.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.