Jump to content

Berre

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Berre's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok. Thanks. I got it to work now. I've attempted using those conditions multiple times, but there seems to have been some issues with caching.
  2. My root directory (in the actual file system) has several subdirectories, one of which is a "main" site, while the others are individual user sites. Every subdirectory has their own .htaccess file, but it's the root .htaccess file that is the topic. I have tried to create rewrite rules myself, but I can't get the rewrite conditions to properly check for the folder existing. /main/lots-of-files /homer/lots-of-files /marge/lots-of-files /bart/lots-of-files /lisa/lots-of-files /maggie/lots-of-files /.htaccess So this is the root of my web server. When I go to sites.example.com I see the directory listing above. I want sites.example.com to point to "/main/" instead of "/". Not only that, but I want everything not specifically pointing to any user dubdirectory to rewrite to /main/. These should not rewrite to /main/, because these directories exists in root*: /homer/index.php /marge /lisa/pictures/profile.gif * The files may not exist in those positions, as /homer/, /marge/, /bart/, /lisa/ and /maggie/ all has a .htaccess file with their own rewrite rules. These should rewrite to /main/: / /philip /bender/bending/rodriguez.php /basically/anything-not-existing-as-a-directory /some-file.txt
  3. <a href="website.com">Click</a> or just visit <a href="example.com">my example page</a> Let's say you want to retrieve all the a tags, in this example 2. The bold text is what is matched, while the underscore is to show you where the criteria matches. The greedy (without ?) will match the entire string, because it doesn't stop at the first match. While the second (with ?) stops matching as early as it can, and will therefor make two matches. Example 1: Example 2:
  4. Berre

    HELP!

    Do you think "HELP!" is a good subject? 100% of the topics here could have that subject. Anyway, I don't understand your problem or what you want to achieve. Your code example doesn't seem to have any problems.
  5. This will match everything inside the brackets; a-z: [a-z] This will match everything but what's inside the brackets; a-z: [^a-z] The code he showed you will match everything but the "<" character, which is when the tag starts closing, and the username in your example is ended. [^<]+ If it's not working, it's probably because you still have "<\/a>" at the end. "[^<]" will not match your string because of the <img> tag. So you could just remove "<\/a>" at the end of your regex, or add information about the img tag.
  6. The "best" way to reuse code would probably be a full object oriented framework. But that's way into the future, so for now just know that whatever you do it will be problematic for you. Everything will get messy, and you'll hate it. But that's how you'll learn A simple way to reuse code is with functions. A function is basically some code you call whenever you need an algorithm run. function get_highest($item_a, $item_b) { if (!is_numeric($item_a) || !is_numeric($item_b)) { return false; } return $item_a > $item_b ? $item_a : item_b; } Example use: $moms_age = 50; $dads_age = 53; echo "The highest age is " . get_highest($moms_age, $dads_age); This is essentially what you do when using strpos() and similar. To make it possible to use the functions on multiple pages you can sort them in their own files, for example functions.php. Then, you just write this in each document: require_once "functions.php"; By including pages (require_once or include_once to avoid the page being included multiple times) you can use the same variables as well, like your database connection.
  7. What do you mean? echo date("m/d/y",time()); This is specifically telling it to display only month, day and year in the first parameter ("m/d/y"). This however will include a 24 hour time at the end. echo date("m/d/y H:i:s",time()); What's the different times produced if you try different locations in date_default_timezone_set(); Does "Europe/Paris" output 1 hour later? And I don't think date_default_timezone_set() will affect MySQL's NOW(), only PHP's time(). I guess your server has the wrong settings (not set timezone correctly or wrong time). I also don't think date_default_timezone_set() will affect the timestamp itself. If you change it, time() will show the time number, but when you convert it with date() it will show different times based on timezone. The timestamp is universal.
  8. What happens if you change date_default_timezone_set() to some other place. Does the time change accordingly? Does "Europe/Paris" show one hour later that "Europe/London"? If so, maybe the server's time is wrong?
  9. I have an external RSS feed that I want to check regularly. The feed doesn't update often (maybe once or twice a week), but when it does, I want to be informed within a fairly short time. RSS readers and such gets updated with only a few minutes after a feed is updated, but are they downloading the RSS file every 3 minutes or is there some other way to ask for last updated timestamp of a document or something? I fear that retrieving external RSS feeds every 3 minutes with file_get_contents() and parsing it with SimpleXML() to look for updates would result in a ban due to continuous hammering. Or is this what all RSS readers does? I don't need to update every 3 minutes or so, but it shouldn't take longer than 15 minutes or so.
  10. I need some help with creating this algorithm. The goal is to find the highest occurrence of overlapping date ranges. Let's say I have some date ranges: 2012-02-21 - 2012-02-24 2012-02-21 - 2012-02-26 2012-02-23 - 2012-02-29 2012-02-24 - 2012-02-27 2012-02-26 - 2012-02-28 Of these the date 2012-02-24 and 2012-02-26 are overlapping 4 times, which is the highest number of overlapping dates. This number (4) is what I want to get. I don't care when the peak is, or how often it peaks, just the highest number of overlapping dates. It's not important with a lot of exact PHP (you don't have to write the entire thing), but I'm completely lost for a simple and fast way of solving this.
  11. Thanks for both explaining and showing. That solved it
  12. I was writing a script that seemed to work flawlessly, but when I tried it on my girlfriends laptop it didn't work. Other JavaScript code worked so it's not disabled, but not this particular script. Both computers (mine and hers) run Firefox 10 (not 100% sure if she has version 9 or 10 though) on Windows 7. It's very early in the process, so I haven't tested it very much in different browsers etc. I just tried it in Chrome on my computer, and it doesn't work there either. Below is the snippet of code that fails. The purpose is to remove all elements with the class name details. var details = document.getElementsByClassName("details"); for (var i in details) { var p = details[i].parentNode; p.removeChild(details[i]); // This line fails }
  13. ^ means that it must be the beginning of the string, and the $ is the opposite, meaning the end of the string. /^[A-Z]+[a-z]*$/ This one will match strings that starts with capital letters. The + sign means that there must be at least one capital letter. After that it CAN match lowercase letters. The * means zero or more hits. This regex would match for example: A FE FFDXFGRGRG Grsgscgf GFEa Gg To match a string containing two names (first and last name), and want to ignore capitalization you could use /^[a-z]+ [a-z]+$/i (the i at the end means case-insensitive). If you use \s it will match other white-space as well (not only space), like tabulator.
  14. I guess I'll make a generic function like that. Thanks
  15. You should probably learn the basics of MySQL before you ask questions. No one are here to make scripts for other people, but rather help with getting them to work properly. http://www.google.com/search?q=mysql+AND+php+AND+(tutorial+OR+introduction)
×
×
  • 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.