-
Posts
15,290 -
Joined
-
Last visited
-
Days Won
436
Everything posted by requinix
-
Why will only disable users work in my code?
requinix replied to slotegraafd's topic in PHP Coding Help
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. -
Find value inside foreach and use if statment on that one
requinix replied to Silverman's topic in PHP Coding Help
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. -
Find value inside foreach and use if statment on that one
requinix replied to Silverman's topic in PHP Coding Help
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. -
Why will only disable users work in my code?
requinix replied to slotegraafd's topic in PHP Coding Help
What's the code for your HTML form? Specifically for the radio buttons. -
Combining time series data with irregular timestamps
requinix replied to NotionCommotion's topic in PHP Coding Help
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. -
Combining time series data with irregular timestamps
requinix replied to NotionCommotion's topic in PHP Coding Help
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? -
Combining time series data with irregular timestamps
requinix replied to NotionCommotion's topic in PHP Coding Help
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. -
Find value inside foreach and use if statment on that one
requinix replied to Silverman's topic in PHP Coding Help
Great. So... problem solved? -
Find value inside foreach and use if statment on that one
requinix replied to Silverman's topic in PHP Coding Help
In other words, "if the field is email && the user is logged in || the field is not the email" then show it? -
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.
-
No idea. Xdebug might have a tool that can help, but I would probably just go through the code and trace where the variables are being stored. Or at least being sent. But like I said in the other thread, don't use destructors as a shutdown mechanism. They're about dealing with memory and resources that were used by the instance being destroyed.
-
debug_zval_dump shows you refcounts, but the very act of passing a value into the function increases the refcount. The solution was call-time byref variables, but that was removed a few PHP versions ago. So the refcount isn't as accurate anymore and debug_zval_dump isn't really useful now. Xdebug provides something else.
-
Session Start - Headers already sent. What am I doing wrong?
requinix replied to MAtkins's topic in PHP Coding Help
Your editor is saving the file with a UTF-8 BOM at the beginning of the file. Tell it not to do that. -
Don't download and install manually. Use your distro's repositories. They exist specifically so you can use them.
-
You cannot delete an object. Stop using it and PHP will delete it automatically. In your example code, $func is using $obj.
-
Don't do at all. ticks are old and fragile when it comes to signal handling. Use pcntl_async_signals like I posted. It will matter when you stop using ticks. If you don't know what zend.signal_check does then read the docs. Don't just guess at what it means. Stop what you're doing and learn about systemd services. Try without and see what happens.
-
Zend Debugger not working in Linux Kali with Apache and Zend Studio
requinix replied to ProgrammingCaveman's topic in Linux
And you restarted Apache? And there's nothing in Apache's or PHP's error logs - just the normal startup messages? If that's still not working then it's going to be some minor thing somewhere. Or you could just ignore it all and install from the repo. -
I was on the phone, be patient. "w" should have done the job, but forget that code. The author doesn't know PHP. file_put_contents("logFile.txt", date("r")); That's all you need. If it's not creating the file then you're probably facing a file permissions issue; create the file yourself, change the permissions to 0666, and try running again.
-
Zend Debugger not working in Linux Kali with Apache and Zend Studio
requinix replied to ProgrammingCaveman's topic in Linux
It compilation didn't work then you wouldn't have an xdebug.so in the first place. Did you edit the correct php.ini or other settings files? Apache and php-fpm and php CLI all use different files. And any particular reason why you are doing all this yourself? If you installed PHP from Debian's repos then why not install Xdebug the same way? -
So there's a small issue. If you just write when the server starts up, you can't actually know if it's still running. All the log really tells you is the last time it started - who knows if it shut down since then. But you say this is a server? Like an actual server running something you can connect to? Wouldn't the easiest way to know if it's running be to simply try to connect to it?
-
Can you be a little more specific than that? What kind of program? What starts and stops it?
-
Look here. Read and try to understand. It's a very small change. But you really don't want to do that. It means only one message will ever be in the file at a time. The most recent message. Everything else got lost. So forget that code. Where did it come from? Whoever wrote it doesn't know about PHP, and getting PHP code some someone who doesn't know much about it is a pretty bad idea. What problem are you trying to solve? In unrelated news, I edited your thread title to put a little more effort into it than you did. Please try to write something useful in there next time.
-
Zend Debugger not working in Linux Kali with Apache and Zend Studio
requinix replied to ProgrammingCaveman's topic in Linux
Is the extension enabled? Does the php.ini setting to enable it use zend_extension= and not extension=? Anything in the error log about being able to load the extension? -
Destructors are about cleaning up resources used by the class and are not suitable as some sort of "shutdown" event. They're tied to variable and memory usage, not script execution. If you want to run some code when the service is shutting down then do exactly that: set up signal handlers as needed to allow your code to terminate gracefully, and/or use register_shutdown_function(). For example, <?php pcntl_async_signals(true); $running = true; pcntl_signal(SIGINT, function() use (&$running) { echo "Caught ^C\n"; $running = false; }); while ($running) { echo "."; sleep(1) && pcntl_signal_dispatch(); } (if you had problems catching signals then it's likely you were missing pcntl_async_signals) edit: ^C is SIGINT, not SIGTERM