Jump to content

requinix

Administrators
  • Content Count

    12,238
  • Joined

  • Last visited

  • Days Won

    268

Everything posted by requinix

  1. Spend a minute reminding yourself about how URLs work. Learn about mod_rewrite's [QSA] flag.
  2. Right. The path portion identifies a particular thing. "Resource". Like the page that shows a category is a resource, and the page showing a particular product is a resource. If you want to change how that source is presented then stick it in the query string.
  3. Yes. It's all much easier if you can set a pattern and use it for one specific purpose. /shop/thing browses a category, /shop/thing/thing shows an item in that category. You don't have to do any complicated logic about whether any part is a particular keyword and then have to change what the page does. Don't have to set up multiple URL rewriting rules to handle different exceptions to each pattern.
  4. Depends on the browser. I think it's common to show it when you're at the top of the page, then hide it as you scroll down. No regular user has ever cared about URLs. For a while people thought making them look fancy was important for SEO, but it isn't. Your URLs should be something that a person can look at and not be afraid of. Like this page, it says "topic" (I am viewing a topic) and it has "mod_rewrite-questions" (that's the title). That's nice and reassuring. If it was just "/viewtopic.php?tid=310679" then that's not as nice or reassuring, but neither your web server nor Google actually care.
  5. What are you going to do if you need to support an item named List or Gallery? Don't mix concepts like this. It's okay to use query strings.There is absolutely nothing wrong with /shop/movies/?view=list. In fact there are some schools of thought that say the path portion indicates a resource and is not where you should be putting aspects of that resource's presentation.
  6. Try it and find out? Spoiler: no Hint: []s are for individual characters. Maybe? You'll have to be more specific than that.
  7. No, it is not invalid. I didn't say it was invalid. I suggested that maybe there was a better way to do what you were trying to do. Because ^(?:^)([a-zA-Z+]){2,26}(\<wbr\>\&shy\;)?([a-zA-Z+]){2,12}?(?:$)$ 1. You have unnecessary (?:^) and (?:$) assertions 2. You put a + in the character set, where it will mean a literal plus and not repetition 3. The parentheses for grouping around the letters do nothing 4. < > & ; are not special characters and do not need to be escaped 5. The anchors and the fact that this looks for the hyphen in a string suggests you're running this regex multiple times to add multiple hyphens? Some of those are minor flaws and some of those impact how the regex works, but mostly it just didn't feel right to me and I'm not sure that it will properly handle all the various inputs you haven't tested yet.
  8. Then I'm not sure why you have this complicated scheme of checking the length of the whole string, and looking strictly at letters. Simple hyphenation is fairly simple: insert a hyphen into a word after about X characters but not within Y characters of its end. Sounds like you're going for X=10 and Y=2, so RequinixIsAregexPro hyphenates as RequinixIs-AregexPro, Ruechenseitentiere as Ruechensei-tentiere, and Ruckenseitentiere as Ruckenseit-entiere. You can adjust your X and Y to make these examples look better, but you can't set up hyphenation rules for every single word. Especially not with German. /\pL{10}(?=\pL{2})/u Find 10 letters, require that there are at least two more after it, and insert a soft hyphen. If you have to deal with HTML then sure it's a lot more complicated. You need to ignore <script>s and their contents, and ignore other tags but not their contents. Basically the only way you can do that is look letter by letter. Count out 10 letters, skipping over HTML as you go. /(\pL(?><(script).*?<\/\2>|<.*?>)*){10}(?=\pL{2})/su
  9. You don't have to do everything with a regular expression. If you want to limit the length of a string, there are easier ways. What you have there is... well, I take it you've spent a lot of time throwing syntax at it until you got something that worked? Do me a favor and state the full and exact requirements for your input string and we'll see if we can't come up with something that does it all in a cleaner way.
  10. How do you want to decide whether to start with "le" or "mini" or "pliable"? Randomly? Put the words into an array and use array_rand to find one. To determine a random number between 95 and 365, use rand.
  11. Before dealing with this, you need to change to using prepared statements. Because as your code is now, someone could submit malicious data into your form and completely screw up everything in your database. Not sure whether you're using PDO or mysqli, but both of them support it. Switch now. It might even fix your problem, too.
  12. You can't create the "map"? And the map is... what? An HTML table? An array that looks like the "matrix array" but has numbers instead of true/false? What have you done so far? What is the output you want to receive?
  13. HTTP/1.0? Really? That's... very surprising. Are you sure you're seeing what's really happening? The browser isn't translating anything to be "nice"? What do your server access logs show?
  14. Write your own code to format the string according to the diff and invert. Not if it there was a fractional part of a day involved. It's not 2 days, it's 2-point-something days. PHP does not have a "just the date" type. There's always a time value... It's still not quite right. Check the docs for DateInterval and format to make sure you're using them correctly.
  15. I didn't mean for you to throw away the code you had before... I meant, you had a specific thing that tried to read each CSV line from the line, using str_getcsv, and instead you replace that with a call to fgetcsv (plus add in fopen/fclose because you have to). Definitely keep the array_combine and whatever.
  16. Oh. Well that's easy: You simply have the diff backwards. $object->diff($date) is the diff from $object to $date, and works like $date minus $object. $today->diff($tomorrow) is positive, $today->diff($yesterday) is negative.
  17. That's how many people feel about it too. Personally, I use whatever is most accessible. If this is an element then I'd rather write this.value over $(this).val(). But for stuff like selectors or events? Even with document.querySelectorAll and global support for addEventListener, jQuery is still easier.
  18. Looks right to me. What do you think those should be?
  19. Oh dear. If you control the server then you don't need to do this. If you don't control the server then the client can just go in and remove this shackle. If the client has not paid up, don't give them control of the site. It's that simple. Wait until the contract is complete and you've received payment before handing everything over to them.
  20. No surprise: you're reading the file line by line and feeding each line to str_getcsv. Switch to using fopen, fgetcsv, and fclose.
  21. Yeah, it was fun times back then. They tried to get us all on one of their other forums, but... ugh. I had been on here before they shut DevShed down and I recommended it to anyone else (who cared about PHP). There are a couple other DS alumni somewhere around here, too. It's definitely good to have people maintaining the forum you use. People who actually, you know, care about it. Who aren't just letting it sit there accumulate ad revenue while running years-old software.
  22. If array_combine is finding that the two arrays ($header and $values) have different lengths then you should troubleshoot for when those two arrays have different lengths. As in if (count($header) != count($values)) { print_r(["headers" => $header, "values" => $values]); }
  23. It no longer exists? I assume it existed when Apache was last restarted?
×
×
  • 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.