Jump to content

effigy

Staff Alumni
  • Posts

    3,600
  • Joined

  • Last visited

    Never

Everything posted by effigy

  1. Not really. You'd be surprised at how many oblivious questions have been posted over the years. Did you try the code on the original post from the first link supplied by Google, or dig through the other replies in that thread?
  2. As requested: Dear idiot, If you would do a google search on "mysql gis zip code", you'll find some examples. Love, effigy
  3. . does not include new lines by default. This can be changed with the /s modifier: /pattern/s
  4. It handles four tags in one--the b, i, s, and u. It is captured so \1 can be used to find the matching end tag.
  5. ...and grouping: /\[([bisu])\](.*?)\[\/\1\]/i
  6. You should be able to group the ranges into one character class: [。-゚ぁ-ん亜-熙]
  7. This area is calling DateInput("date", true, "YYYY-MM-DD"). After the page loads, I get an error in my javascript console saying "DateInput is not defined."
  8. I would compact it to: <?php $code = preg_split('/^(\[page=.+?\]|\[url=.+?\].+?\[\/url\])/m', $row['code'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($code as $line){ preg_match('/^\[([^=]+)/', $line, $matches); switch ($matches[1]) { case 'page': echo preg_replace('/^\[page=(.+?)\]/', '<h3>\1</h3>', $line); break; case 'url': echo preg_replace('/^\[url=(.+?)\](.+?)\[\/url\]/', '<h4><a class="redLink" href="\1">\2</a></h4>', $line); break; default: highlight_string($line); } } ?>
  9. Place this before your foreach, refresh, and view the source: print_r($code);
  10. See this topic for more information on your error. PHP Freaks: Introduction to regular expressions (#1): General Mechanics Regular Expression Tutorial
  11. You could do it this way... <pre> <?php for ($i=1; $i<=6; $i++) { $name = "name_$i"; $$name = $i; } echo $name_1; echo $name_2; ?> </pre> ...but I recommend using an array: <pre> <?php $name[] = null; for ($i=1; $i<=6; $i++) { $name[] = $i; } print_r($name); ?> </pre>
  12. You can query the database to see if it already exists, or set up a try/catch or Exception class to handle the error.
  13. Try a callback: <pre> <?php $urls = array( '"http://chaimai.com/index.php?board=2.0"', '"http://chaimai.com/index.php?topic=1654.0#new"', '"http://chaimai.com/index.php?action=dictionary;sa=details;id=83239"' ); $scripturl = 'http://chaimai.com/index.php'; function fix_urls ($matches) { print_r($matches); list($url, $type) = $matches; switch ($type) { case 'board': // Regex... break; // ...and others. } }; foreach ($urls as $url) { echo $url, ' => '; $url = preg_replace_callback('/' . preg_quote($scripturl, '/') . '\?(board|topic|action)[^"]+/', 'fix_urls', $url); echo $url, '<br>'; } ?> </pre>
  14. Yes and no. Less typing means less chances to make an error and also less code to look at it. These are huge benefits when trying to minimalize human error. (And don't forget the intuitive negated shorthands, \D and \S for instance.) The non-typing benefits come in to play when Unicode and locales are considered; however, if you know you're working with Unicode, I think it's better to use the \p{...} properties.
  15. You're running two processes. First, is found and transformed, then isn't found, so the else passes it through highlight. You need to reorganize your if/elses into if/else if/else.
  16. The best practice I suggested; placing the hyphen first in the list. It can be confusing for others because you have back to back ranges with the "loose" hyphen mixed in. If someone has to the change the pattern, they might create a subtle bug without realizing it. Yes. Actually, for such a small, simple pattern, A-Za-z without the /i would be best. This saves the engine from doing the extra work of case conversion.
  17. What does table_b look like? Can you show some example data? I googled for "mysql many-to-many."
  18. Ah; OK. When posting, you should be able to click "Additional Options..." and "Don't use smileys." to disable the bbcode.
  19. It's the data. The patterns were not set up to allow a space between "[" and "url".
  20. There's mod_deflate. I've no experience with it.
  21. Regular expressions are contained by delimiters, and modifiers follow the last delimiter, like so: /pattern/modifiers. You cannot use the delimiter within the pattern unless you escape it, because that throws the containment off. I suggest choosing delimiters that are not used in your pattern; the percent sign is usually a safe choice: %pattern%modifiers.
  22. Apparently 4.3.10 requires the link: string mysql_real_escape_string ( string unescaped_string [, resource link_identifier] )
  23. Is this in a function or procedure? If so, declare the variable beforehand: DECLARE Supervisors_temp VARCHAR(50);
  24. We'll need to see the code and the data it's working with.
  25. I wouldn't do that; it can be confusing. Did you look into the A-z range? That's going to allow [, ], \, ^, _, and `.
×
×
  • 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.