Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. My approach to such conditionals (anything which is not immediately understandable) is to factor it out like this: $rank_test = $_SESSION['userrank'] >= 3 && $_SESSION['userrank'] != 8; $username_test = $_SESSION['username'] == $row['t_op']; if ($rank_test || $username_test) {
  2. The statement looks fine to me. Try this: print "Comparing {$_SESSION['username']} with {$row['t_op']}<br>"; if($_SESSION['userrank'] >= "3" || $_SESSION['username'] == $row['t_op']){ echo "I am allowed to do stuff"; }else{ echo "I am not allowed to do stuff =("; }
  3. You probably need to drop the foreign key relationship before altering. Is that what you are asking?
  4. That looks good, but the line in the loop might be $favorites[] = $data[0];
  5. CGI? That's an old term. PHP scripts were called "CGI" a long time ago. http://en.wikipedia.org/wiki/Common_Gateway_Interface
  6. Why don't you just search the ISBN's in the database as they are? Is there a reason that you want to remove the "-"?
  7. A form doesn't necessarily mean checkbox or submit button. Google for "submit form with link" will give you plenty of examples. Is it just the appearance of the download link that you are concerned about?
  8. This is what I meant. I have marked the changes. Two lines were changed. while(true) { $sockets = $tab_utile; socket_select($sockets, $lecture = NULL, $except = NULL, NULL); foreach($sockets as $key => $sock) { # <--- change if($sock == $creation) { if(($client = socket_accept($sock)) === false) { echo "Impossible d'accepter le client : ".socket_strerror(socket_last_error())."\n"; exit(); } else { echo "Client accepté.\n"; } array_push($tab_utile,$client); } else { socket_recv($sock, $buffer, 2048, 0); if($buffer != NULL) { echo "Message transmis : $buffer\n"; $tab_envois = $tab_utile; array_shift($tab_envois); envoi_message($tab_envois,$buffer); } else { socket_shutdown($sock,2); socket_close($sock); unset($sockets[$key]); # <-- change } } } } Can you try this code and tell me what happens?
  9. Ok the root problem there is in $rides->find($application->application_ride_id). I can't help you more unfortunately, as I'm not familiar with the framework. But if you fix that, the second problem (line 143) should fix itself.
  10. You can delete from arrays like this: foreach ($array as $key => $val) { unset($array[$key]); }
  11. Yes, having the same name could be a problem. Try giving them different names.
  12. After closing the socket did you remove it from the $sockets array?
  13. You can use $_SERVER['REMOTE_ADDR'] instead of @$REMOTE_ADDR As for doing the recording, can you record it inside abyss.php? At that stage you know both which file is selected and what the user's IP address is.
  14. The die() should go here instead: switch($this->_getParam('application-action')) { case 'approve': die(ride->ride_spaces_available.' == '.$ride->ride_spaces_taken); if ($ride->ride_spaces_available == $ride->ride_spaces_taken) { The reason being that code is not allowed after a switch but before a case (as php would not know which case it is supposed to be executed in).
  15. This almost gets you there: $str = 'ThisIsBestPhpHelpSite'; print preg_replace('/([A-Z])/', ' $1', $str); You'll have an extra space at the front which you can strip off (eg using trim()).
  16. Are you familiar with sessions? Assuming you are, let's say you want someone to access page B only from page A. When they access page A, you store a value in the session like $_SESSION['lastpage'] = 'A'. Then when they access page B, you can check if $_SESSION['lastpage'] is set to A. If you are concerned about users passing data as arguments to the page, then you should store that data on the server instead.
  17. You're right, i can see the quote in the source of your post but not when it's displayed .. maybe a bug in phpfreaks. The code looks ok to me .. one approach you could try is finding a website that successfully pops up a window for you, and copying their code (or examining it to see how it differs from yours)
  18. You can do a simple (and easily bypassable) attempt by checking to see if $_SERVER['HTTP_REFERER'] is set. Typically that value is set when a link is followed, but not when it's typed in. This method is however easily bypassed by someone who wants to bypass it. A better answer is you can use sessions to track your user, and remember where they are allowed to go. Then you can tell them "Sorry, you can only access this page from this other page, and my session data says you didn't".
  19. Those times are WAY WAY too slow, especially for such small rows. So I would look into what is taking the time. Database speeds are measured in transactions per second, but you are getting barely 1 or 2 simple inserts per second there (unless I have misunderstood). I would expect your entire 100 record test to finish in no more then 2-3 seconds. You should get that speed whether you use Mysql or Postgresql or anything else. It's possible that other users sharing the server are slowing it down. It's also possible that network latency is affecting things (network latency can be a real killer if you do many small queries). Is everything running on the same local network?
  20. There's a quote missing before view_image.php there. Which browser are you using? There should be javascript console somewhere that will show you what errors are found.
  21. Nope. You must make two separate calls. Your error handling should report a different message if the first call fails to if the second call fails, so you can fix the problem more easily. You don't have to report a different message to the user, but you should at least notify yourself of where the failure happened.
  22. You must call mysql_query() after setting $query each time. So it will be like 1. $query = ... 2. mysql_query($query) 3. $query = ... 4. mysql_query($query) It's possible to run two queries in a single call, but not recommended as it makes it difficult to handle errors.
  23. According to the manual for pcntl_signal() you must declare ticks = 1, have you done that?
  24. The function was available in windows from php 5.3.0. If your php is older than that, you can use the pear package Net_DNS. Details are in the manual: checkdnsrr()
×
×
  • 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.