Jump to content

requinix

Administrators
  • Posts

    15,288
  • Joined

  • Last visited

  • Days Won

    436

Everything posted by requinix

  1. We use Sphinx here. I won't claim to know much about it, but I am generally pleased with it. A pure PHP solution probably won't be too good. You should have something running in memory to perform searches, and regular databases can't handle that kind of work.
  2. Why not pass the variable in the first form so you don't need the second to retrieve it? Anyway, your form isn't going anywhere. Shouldn't the action be some URL?
  3. Then it's more complicated. Can we get some clarification about exactly how week numbers are supposed to work? Is it ISO 8601 but using Wednesday as the start of the week, so week 1 is - First week with 4+ days in January - First week with the Monday Wednesday closest to Jan 1 - The one with Jan 4 in it - The one with the first working day, not counting Saturday or Sunday (weekends) or Jan 1 (New Year's Day) I suspect so, in which case you'd have to emulate the same logic. Not sure if there's an easy way that works for all days of the year, or else just do a condition on whether the day is December 29 - January 10 for the special logic and the -1 week stuff for the rest of the year.
  4. After four hours of searching, maybe it's time to try to solve the problem rather than continue trying to find somebody who has done it before. Assuming that "W" worked perfectly for you before (because it may do unexpected things at the beginning of the year) then, As documented, "W" starts on a Monday. That means Monday and Tuesday dates will be one week number ahead of where you want them to be. You could just -1 but that will cause problems for the first M/Tu of the year. - If today is a Monday or Tuesday, pick the day one week earlier, otherwise use today - Get the "W"eek number of that date if (date("N") <= 2) { // monday or tuesday $date = strtotime("-1 week"); } else { $date = time(); } echo date("W", $date);
  5. 1. The mysql extension and its mysql_* functions are old and unsupported. You need to start moving to either PDO (recommended) or mysqli. 2. I sure hope $search was escaped before you put it into that query. 3. die()ing with the MySQL error message is dangerous, not to mention a bad user experience. A Refresh value needs to be structured as "seconds;url=path", with the first part being a number of seconds to wait to redirect. 4. A meta refresh (as it's called) is a poor way to move users between pages. Use a header() redirect if you haven't created any output or display a message with a link on the page if you have.
  6. Are the files all constant-rate 128Kbps? Have they been stripped of all ID3 tags? $showsize is in KB so the /1000 would be both wrong (check the man page for what -k means) and unnecessary. 34308 KB * 8 = 274464 Kb / 128 Kbps = 2144.25 sec = 35:44. So there's something else going on.
  7. $saleprice is being outputted into the HTML somewhere. That's where you should add the span. But first look to make sure there isn't already a way to style the element as it currently exists on the page.
  8. Note that what you have will check if there's that 5-4 somewhere inside $input. As in it will quite happily match with $input = "a bunch of stuff then 12345-6789 and then more stuff";If you want to make sure $input has only that 5-4 then you need ^ and $ anchors to mark the beginning and end of the string. '/^\d{5}-\d{4}$/'
  9. You're right, it is quite simple. So what have you tried and what was the problem you had with it? I bet what you came up with was really close.
  10. Thanks for the thought, but we don't really take donations - at least not for the time being. However if an individual member (or more than one) has been particularly helpful then they might be willing to accept it.
  11. If you know that you want a FlashButton then go ahead and use that. But if all you know is you want a $b button then you don't very well want to have to go through the work of deciding which class to use, right? Easier to have some other code do that for you.
  12. Then what you're describing is not possible. 1. You didn't mention where you put the var_dump, but assuming it came sometime after the (unnecessary) foreach loop then it shouldn't matter. 2. The crazy indentation suggests you pieced together your post from different pieces of code, rather than from one complete block. 3. You say it executed the default case - how do you know that? Have you put debugging statements (eg, an echo) in each case to see whether it really is executing that way?
  13. Did var_dump($cname) show exactly string(4) "CASH"
  14. Yeah... we've been back for a while now. It was only for a month or so.
  15. ÿ + R, "psr" (if you see a ÿ then you don't have the wingdings font)
  16. I think I used 'd' accidentally, but regardless my thought process was that the number of days would be less than the length of a month... but there will be cases where that's not true, even though a handful of conditions have to be met for it. Good catch.
  17. Huh. You'd think "Number of days" would be the right one... I guess "total number of days" is the better choice :-\
  18. The location of the site code on the server has absolutely no bearing on the domain name. You can put the files anywhere you want so long as you have your virtualhost config set up with the right ServerName and the right DocumentRoot.
  19. I'm not really sure what you're trying to do with DatePeriod... Anyway, you can't use date("W") because that has weeks starting on Monday. It's also for the entire year, not just a month. I don't think there's anything built-in to do this already so you'll have to come up with it on your own. 1. Find the last Friday of the previous month 2. Find the last Friday of the current month 3. Pick a starting Friday based on those 4. Calculate the number of days between that Friday and the current date function week_number(DateTime $date) { // previous month's last friday $previous = new DateTime($date->format("Y-m-d") . " last Friday of last month"); // this month's last friday $current = new DateTime($date->format("Y-m-d") . " last Friday of this month"); // pick a starting friday if ($date >= $current) { $start = $current; } else { $start = $previous; } $diff = $start->diff($date); // $diff = $date - $start return floor($diff->d / 7) + 1; }And a quick test: foreach (["01", "02"] as $month) { $start = new DateTime("2017-{$month}-01"); echo $start->format("F Y"), "\n"; echo "Su Mo Tu We Th Fr Sa\n"; echo "--------------------"; if ($start->format("w") > 0) { echo "\n", str_repeat(" ", $start->format("w")); } foreach (new DatePeriod($start, new DateInterval("P1D"), $start->format("t") - 1) as $day) { if ($day->format("w") == 0) { echo "\n"; } echo " ", week_number($day), " "; } echo "\n\n"; } January 2017 Su Mo Tu We Th Fr Sa -------------------- 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 1 1 1 1 1 February 2017 Su Mo Tu We Th Fr Sa -------------------- 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 1 1 1 1 1
  20. Conventions are just guidelines. Personally I would make "magical" its own site at /var/www/magical.com but fact is it doesn't really matter. You could have spent the last 4.5 hours working on your site instead of trying to decide where to put the files.
  21. Then you need to change the configuration to use /vagrant/myproject.com/public/Magical as the document root instead. But can I assume you already thought of that?
  22. requinix

    linux command sed

    root@*:~# cat test.txt [quote name="ajoo" post="1543020" timestamp="1487487301"] I have tried them out in the terminal as a modified example :- sudo sed -i, s,www,the,g test.txt. where test.txt has 2 lines of some text containing the word 'the' a couple of times.The command seems to do nothing. There is no change in test.txt. [/quote] Try putting "www" in it instead. root@*:~# sed -i s,www,the,g test.txt root@*:~# cat test.txt [quote name="ajoo" post="1543020" timestamp="1487487301"] I have tried them out in the terminal as a modified example :- sudo sed -i, s,the,the,g test.txt. where test.txt has 2 lines of some text containing the word 'the' a couple of times.The command seems to do nothing. There is no change in test.txt. [/quote] Try putting "the" in it instead. root@*:~#
  23. Looks like that repo is not compatible with PHP 7. Can you settle for using the binaries instead of an extension?
  24. That's right! I'm glad you've suddenly become familiar with the rules. Now how about giving OP a chance to redeem him/herself?
×
×
  • 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.