Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. If you query ranks a lot more often than you change them, then it may be worthwhile re-calculating all the ranks every time they are changed. You can store the ranks in a second table and join them. To improve on update times, you could use a bubble sort style method to bubble any altered entries into their correct position. For example: A 4 B 3.5 C 3 D 3 E 2.5 F 2 Let's say E gains 1 point. Then we bubble it up one step A 4 B 3.5 C 3 E 3.5 D 3 F 2 But it's still not in the correct position, so we bubble it up again A 4 B 3.5 E 3.5 C 3 D 3 F 2 Ok, now it's in the right order. This would only involve changing the auxiliary table which holds the ranks.
  2. I think the value he wants is the player's rank according to a specified sort order. The player is specified, and the output he wants is rank according to "winpercentage DESC,played DESC,banktotal DESC"
  3. You can't store resources in $_SESSION. When a request terminates, all resources are closed, including your socket. Data is later reconstituted from $_SESSION on the next request, but by this time the connection has been closed, so the handle you stored in $_SESSION is meaningless.
  4. Actually it can.. I even use UTF8 encoded foreign language strings as array indices. Plenty of them have spaces inside. An associative array index can have anything a string can have.
  5. I'm having trouble understanding your question. You would like to read data directly from postgres and send it to another destination? But currently you can only export the data in csv format?
  6. That's quite an odd query. Did you mean this: $sq = "SELECT rate.dest_zip FROM rate_carriers INNER JOIN bols ON bols.rid = rate.rid INNER JOIN rate ON rate.rid = rate_carriers.rid WHERE b.pro_num = '$pn'"; $result = pg_query($sq) or die("Error: Could not find destination zip");
  7. Try this out: <script type="text/javascript"> function show_div(div_name) { var my_div; my_div = document.getElementById ? document.getElementById(div_name) : null; if (my_div) { if (my_div.style) my_div.style.display = ''; else if (my_div.display) my_div.display = ''; } else { //alert('Cant find ' + div_name); } } function hide_div(div_name) { var my_div; my_div = document.getElementById ? document.getElementById(div_name) : null; if (my_div) { if (my_div.style) { my_div.style.display = 'none'; } else if (my_div.display) { alert(div_name); } } } </script><div id="foo">Hide me</div> <input type="button" name="Show" value="Show" onClick="show_div('foo')"> <input type="button" name="Hide" value="Hide" onClick="hide_div('foo')">
  8. A google search for "ER diagram software" shows up many packages for developing ER diagrams. I can't recommend any as I haven't used them myself. If you haven't heard of ER diagrams, take a look here But designing a good ER model is still an art form, even if you have software to help. It's something that takes trial and error.
  9. I'm not sure you got what I was saying. If you run your script again while your script is already running, then the second run will wait for the first to complete. It's not about how many times you call session_start() within the one application. Is it possible that the problem pages don't terminate until they reach the timeout, which is 30 seconds by default? Also, do you know if your site is hosted on multiple load-balanced servers or a single server? session_start()'s locking does not function if the session file is shared over nfs. This has given me behaviour where I would seemingly randomly get long delays, but other times I would get instant response.
  10. Are you doing multiple requests simultaneously? session_start() will block until any previous request for the same session has completed.
  11. Yes that makes sense. I would convert both to seconds and then do the calculation, then convert back. You can use the date and time functions. I'm not sure exactly which you'll need, but strtotime() is often useful. So is mktime(). The final one is date(), which can format your timestamp as a date again.
  12. Yes it's possible.. see here: http://www.mail-archive.com/internals@lists.php.net/msg24299.html which links to http://cvs.php.net/viewvc.cgi/pecl/rar/config.m4?revision=1.6&view=markup
  13. I really don't understand what you want. Can you give an example? I would have thought finish time is start time + duration, but it's more complex than that?
  14. Jenk, I think what 448191 is asking is that you restrict any further discussion to php daemons only, as he has already chosen PHP as the language to use. I get that you think Java or C would be a much better choice. 448191 gets that too. I don't think he disagrees with you either. He's just asking you to stop discussing other languages in this topic. He's not saying "PHP is better for daemons than Java".
  15. The problem of people changing the address bar is solved by checking the values they submit and verifying them. There's no easy way around that. If you want to avoid showing the values in the address bar then you can use post instead of get. But that provides no additional security. You must still verify the values.
  16. Here's an example.. let's say you have 4 apples, 3 oranges and a banana. Then someone gives you 2 apples and 2 bananas. You can write it as: 4a + 3o + b (what you start with) 4a + 3o + b + 2a + 2b (plus 2 apples and bananas) = 6a + 3o + 3b (the total) That may not seem so useful, but it gives an idea of why you might want to keep the like terms together. It's because each term represents some different thing in reality. It's possible that terms are equal, but until you know they are you have to keep them separate, because they might be different. Maybe what you thought was oranges were actually bananas (and you need new glasses), so you can merge b and o into b.
  17. Ok, that simplifies things. Your scripts are buggy Add some code at the top of each script that dumps the session data straight after session_start(). I'm sure that you will see pages with session data but which think that you are not logged in.
  18. Do you mean with username and password?
  19. I think you should ask your teacher about it. Isn't there a description of the problem at the top of these questions? Some kind of explanation of what you should be doing?
  20. Unlisted will use the default value. But you can set it if you want, it won't hurt. If you make a simple session page which does nothing at all and refresh it a few times, does that work? This is just to verify that sessions are in fact working properly. After that, you can get to looking at why your code in particular isn't working with sessions. The problem may be hidden in an include() somewhere, or in one of those functions you call.
  21. Can you post your header.inc.php ?
  22. Won't objects be garbage collected once they go out of scope? I've used php for daemon style applications with no problems at all. But I have not used OO style php for daemons. I don't see how it would be easier to write a daemon in C than PHP. And although there may be minimal differences in syntax between java, C and PHP, there are huge differences in semantics. Memory management and strict vs loose typing are obvious examples.
  23. PHP already uses doubles, so I doubt you'll see any improvement in C unless you have a method to extend beyond double precision. The Zend engine has no single precision float type, only double. It's all here
×
×
  • 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.