Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Still not getting the dropdown. I noticed the spammer. I used to be able to flag spammers but there is only the "befriend" icon now.
  2. I got an email and a red flag to inform of notifications on receipt of this reply. No items in the notification dropdown though.
  3. You don't have to change now, you can leave it until the functions actually disappear. But by then you will have much more to to change and no time to do it. The choice is yours.
  4. The red flag on the notification icon at the top tells me I have notifications. On clicking the icon the notification menu is empty. This started today sometime.
  5. Have you seen this page yet? http://php.net/manual/en/mysqli.real-escape-string.php
  6. Perhaps if ($entry[1] == $field) { echo get_avatar(); }
  7. It is looping and trying to find the max number of balls. To do this it compares the new count with current max. If the new count is greater than the current max then we have a new max. To do this you have to set the current max to 0 at the start. If it were set to, say, 999, then you would never get a new count greater than the current max. If you sort you balls in the groups by weight, and always start with the most balls from the heaviest group, heaviest group then that should help.
  8. Test the year diff. This assumes you set the bantime to '9999-12-31' if banned permanently $expire = $myrow["bantime"]; $dt1 = new DateTime($expire); $dt2=new DateTime(); // Now $dif = $dt2->diff($dt1); if ($dif->y > 1000) { // if more than 1000 years $diff = 'PERMANENTLY'; } else { $diff = $dif->format('%m months, %d days, %h hours, %i minutes, %s seconds'); } print $myrow["user"]. " - " . $diff . $banu;
  9. No, it wouldn't help much doing it like that. The reason for testing is so you DON'T do a calulation. while($myrow = mysql_fetch_array($result)) { $ip = mysql_real_escape_string($myrow["ip"]); // WTF is this meant to achieve? $expire = $myrow["bantime"]; if($expire === "PERMANENTLY") { $diff = "Permanently"; print $myrow["user"]. " - " . $diff . $banu; }else{ $dt1 = new DateTime(); $dt1->setTimestamp($expire); // SET TIMESTAMP VALUE (RTFM) $dt2=new DateTime(); // Now $dif = $dt2->diff($dt1); $diff = $dif->format('%m months, %d days, %h hours, %i minutes, %s seconds'); print $myrow["user"]. " - " . $diff . $banu; } Why don't you use a DATETIME field. Then you can set a ban up to '9999-12-31 23:59:59', which is fairly permanent, and won't give you these problems with inconsistent data type in the same field
  10. You need to make up your mind whether that column should be a time stamp or not. You seem to want to throw anything into it. Given what you have you need to check for 'PERMANENT' before you attempt any calculations on the value.
  11. And as I indicated, sometimes your date format will be valid (even if not interpreted correctly), sometimes it won't
  12. Your date formats could present a problem EG echo date('Y-m-d', strtotime('25/12/2014')); // d/m/y format - gives 1970-01-01 X echo date('Y-m-d', strtotime('25-12-2014')); // d-m-y format - gives 2014-12-25 ok echo date('Y-m-d', strtotime('12/25/2014')); // m/d/y format - gives 2014-12-25 ok for UK d/m/y it doesn't like / but d.m.y or d-m-y are ok / is ok for US m/d/y format Better to stick with universal Y-m-d format
  13. here's the age function I use function age($dob) /** * $dob - a valid date format (Y-m-d, d-M-Y, m/d/Y, d-m-Y etc) */ { if (!$dob) return "n/a"; $t = strtotime($dob); $age = date('Y') - date('Y', $t); return date('md', $t) > date('md') ? $age-1 : $age; }
  14. You get 1938 years because you are using a unix timestamp. If you do it that way you need $dt1 = new DateTime(); $dt1->setTimestamp($expire); // SET TIMESTAMP VALUE (RTFM) $dt2=new DateTime(); // Now $dif = $dt2->diff($dt1); echo $dif->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds');
  15. 1 hour = 3600 seconds. 3600000 seconds, which you are adding, = 41 days 16 hours And there is an easier way of getting a date difference $dt1 = new DateTime('2000-01-01'); $dt2=new DateTime(); // Now $dif = $dt2->diff($dt1); echo $dif->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds'); // RESULT---> 15 years, 2 months, 2 days, 15 hours, 15 minutes, 15 seconds
  16. Given your constraints you can pick a maximum of 9 balls (5 + 2 + 1 + 1) from the four groups so shuffle the groups then pick five from the first, two from the second and one from each of the remaining two groups. Brute force method $target = 10; // max product of numbers chosen from groups $result = array(); $max = 0; // max ball count $g1 = count($balls['Group1']); $g2 = count($balls['Group2']); $g3 = count($balls['Group3']); $g4 = count($balls['Group4']); for ($a=1; $a<=$g1; $a++) { for ($b=1; $b<=$g2; $b++) { for ($c=1; $c<=$g3; $c++) { for ($d=1; $d<=$g4; $d++) { $prod = $a*$b*$c*$d; $tot = $a + $b + $c + $d; if (($prod <= $target) && ($tot > $max)) { $result = array($a,$b,$c,$d); } } } } } echo join (' + ', $result); //==> 5 + 2 + 1 + 1
  17. Numeric variables should not contain formatting characters such as commas. Same goes for values held in a db table. 4,100 is treated as 4 (only numeric digits up to the first non-numeric digit) Format the numbers on output
  18. this worked ok for me $x= ' '; if (empty(trim($x))) { echo 'empty'; }
  19. Yes, you could write a single query to do that, but why bother storing data that can be easily derived by the same query. A basic principle of db design - don't store derived data.
  20. to get that error you would be trying to assign a value to a function call EG if (trim($x)='') { So what is the real code that is giving you that error?
  21. try if(empty(trim($_POST['formName'])))
  22. Take a VB script, add a few $ prefixed variables. Yes, that'll do it
  23. Use (..) to ensure the logic you really want WHERE approved = "1" AND (item_gender="1" OR item_gender="3") otherwise the logic defaults to WHERE (approved = "1" AND item_gender="1") OR item_gender="3" Alternatively, use IN instead of multiple ORs WHERE approved = "1" AND item_gender IN (1, 3)
  24. LOL join is exactly the same function as implode()
  25. Move the "unset()" out out of the statement. It isn't trying to unset the GET variable, it is trying to unset the boolean result return by the isset() function.
×
×
  • 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.