Jump to content

requinix

Administrators
  • Posts

    15,071
  • Joined

  • Last visited

  • Days Won

    414

Everything posted by requinix

  1. It'd be nice if you spent the bit of time it takes to write a description of your problem, rather than just use the one-line title to cram everything in. Leaves us with questions like "What problems with your while loop?" As for the other issue, Putting aside the malformed HTML, You can't put a button inside a link. Pick one. However if you need to pass a value then you can use a like DeleteTo make that work, though, you need the current script (the one that handles editing) to support deletes too - can't have a form inside a form, and shouldn't try to switch the action of a form based on a button. There's HTML 5 stuff you could do, actually, but I probably wouldn't.
  2. Sometimes it takes more than an hour to get an answer. It'd be easier to check for any items that are not Dispatched than to check that all items are.
  3. I blame my sick boss for making me sick too and thus not quite in my right mind. But at least I did get the $n=>.
  4. If you used file_put_contents instead of fwrite(), you'd have yourself a winner. But I'd do it a bit differently: $lines = file("animals.txt"); foreach ($lines as $n => $line) { if (stripos($line, "cat") !== false) { $line = rtrim($line) . " Be careful with cats!" . PHP_EOL; } } file_put_contents("animals.txt", $lines);If the file was much larger, though, (and 100MB may be too large already,) you'd need to use a different tactic: you'd run out of memory to store the entire file in PHP's memory.
  5. Why not? You say "should look at the previous entry" I would expect that looking at the times would be the best way to do that. If you're not using an auto_increment column already then you can add one as part of a composite key like (account_id, entry): the will count from 1 per account_id, so you'll know for a fact that the previous entry was (account_id, current entry-1).
  6. Does it actually have to be an , or do you only want it to look like a link? And I take it that means you don't want the image anymore and will be using some plain text instead (eg, "Continue")?
  7. Use CSS classes. Put all the HTML you want into the header thing: the image as one thing, the "some HTML content" as another (but put inside a container like a DIV or SPAN). Put a class on each indicating when you want it to show, as in <div id="header" class="has-cookies no-has-cookies"> <img id="headimg" class="cookies"> <div class="no-cookies">(whatever)</div> </div>Create CSS rules like div#header.has-cookies > .no-cookies { display: none; } div#header.no-has-cookies > .cookies { display: none; }1. header is "empty" by default because it has both of the has-cookies/no-has-cookies classes2. Your Javascript removes the has-cookies or no-has-cookies class (whichever shouldn't be there) which causes the appropriate content to appear 3. If they have cookies you also set the headimg image (you should do that before #2) Some of this code looks a bit off so I tried to fix it, including making it use jQuery for real. $( document ).ready(function() { var code = getVar('agent'); if (code) { SetCookie("code", code, 1); } else { code = ReadCookie("code"); } var img = new Image(); var imgsrc = "images/" + code + ".gif"; img.onerror = function (evt) { // $("#headimg").attr("src", "images/no-cookie.gif"); $("#header").removeClass("has-cookies"); } img.onload = function (evt) { $("#headimg").attr("src", imgsrc); $("#header").removeClass("no-has-cookies"); } img.src = imgsrc; });
  8. explode()s third argument lets you limit the number of items to, say, 3, with the third having the rest of the string.
  9. You may need to call session_write_close() before starting another session. Also keep in mind that session_id() will cause a new session cookie to be sent, so there'll be one for the second session and another for the first session (when you switch back to it).
  10. Not that I know. Try not to make a habit out of switching between sessions though.
  11. Sure. Javascript is a programming language. It can do things like add two strings together. $('#popup').load("../help-file/"+ page + ".php"); // I'm guessing at the path
  12. Is page a proper URL? Can you actually skip loop.php, like are the things it does not terribly important? Then sure: don't use loop.php and .load() the page directly.
  13. You should also exit; after doing that, but no, in that tiny bit of code you posted there isn't anything obviously wrong.
  14. Works fine for me. That's the exact code and XML you're trying?
  15. That [^] has the characters to allow. If you want to allow @ and . then all you have to do (at least for those two in particular) is to add them to the set.
  16. Current URL? Is this always running for a file that's in a subdirectory and not like /file.php? dirname($_SERVER["REQUEST_URI"])
  17. String functions certainly could do it, though it's a little harder since you need to do error checking (eg, what if there is no "dog" or "cat", or what if "dog" comes after "cat"). The regex version would be $output = preg_replace('/dog.*cat/', 'animal', $input);
  18. Everything in $_SESSION stays the same.
  19. Doesn't matter because session_regenerate_id() doesn't delete the data. It's going to change the session ID, which is the entire point of session_regenerate_id(), but the data stays the same.
  20. Did you check the actual values of $start and $end?
  21. What's the most obvious thing to try? Have you tried it? Or what have you tried?
  22. The three numbers from uptime are load, which is (more than) a measure of how active the CPUs are. Say, 0.01 per percent per CPU, so a 2-CPU machine at 100% CPU would show 2.00. But the numbers can go higher. The three correspond to the average load over the last 1, 5, and 15 minutes. if (preg_match_all('/\d+\.\d\d/', $output, $values)) { list($one, $five, $fifteen) = $values[0];With the headings, free shows total used free shared buffers cached Mem: 2040152 1926196 113956 248 26764 1724268 -/+ buffers/cache: 175164 1864988 Swap: 2093052 0 2093052The first three numbers give you everything you need (measured in KBs) and you can grab them easily with if (preg_match_all('/\d+/', $output, $values)) { list($total, $used, $free) = $values[0];
  23. It is not. Removing space is to help with bandwidth usage but PHP doesn't use that.
  24. Ah. Shared hosting. That explains it. 1. You're using enough resources that there's a risk of the machine running out and your hosting provider isn't going to like that. There's probably wording in the ToS to that effect. 2. You can generally get information like CPU and memory usage on a machine, but it's only worth it if you can target a very specific setup - not just Windows vs Linux but which version running in what environment. And on shared hosting the tactics you can use are often unavailable as half the time they involve you running something through exec() or system(). 3. You're pushing the bounds of what shared hosting can provide. Consider upgrading to dedicated hosting. ps gives a full breakdown by process. You need overall statistics. Try uptime for load (a better indicator than CPU usage) and free for memory usage.
×
×
  • 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.