Jump to content

thebadbad

Members
  • Posts

    1,613
  • Joined

  • Last visited

Everything posted by thebadbad

  1. I'm pretty sure that's not the only reason they're doing it. And it's not like I'm revealing some dark secrets of hacking; the data is publicly available (not necessarily meaning that you're free to do anything with it though). But if they offer an API like jon23d mentions, you might as well just use that instead. That is if the OP actually wanted to grab the data from eBay, and not just mentioned it as a pure example.
  2. You're putting $index inside single quotes. And $index isn't the URL, but the actual source code, right? In that case use @$dom->loadHTML($index);
  3. I guess you would need a javascript parser for that. But going along the lines of The Little Guy's post, I found out that the eBay descriptions are retrieved from http://vi.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item=ID where ID is the item ID. So starting out with a sample URL like http://cgi.ebay.com/ASKSOS-ROMAN-EGYPTIAN-FRAGMENTARY-1600-YEARS-OLD-NR_W0QQitemZ380163697044QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item588385a994&_trksid=p3286.c0.m14 we can grab the item ID directly from the URL and then get the description. eBay uses their own query string syntax, with QQ instead of &, and Z instead of =, in case you didn't notice. <?php $url = 'http://cgi.ebay.com/ASKSOS-ROMAN-EGYPTIAN-FRAGMENTARY-1600-YEARS-OLD-NR_W0QQitemZ380163697044QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item588385a994&_trksid=p3286.c0.m14'; preg_match('~QQitemZ([0-9]+)QQ~', $url, $match); $desc_url = "http://vi.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item={$match[1]}"; ?>
  4. Wrong forum. Where's the fun if you don't show us the source code? Also, when I enter test estt and searches for te, the vertical match isn't found.
  5. mikesta707 beat me to it, but here's my (pretty identical) explanation. myusername in your case is a key in an associative array (meaning the keys are string, not integers), and therefore it should be in quotes. Just like you would write $key = 'myusername'; echo $_SESSION[$key]; and not $key = myusername; echo $_SESSION[$key]; Without quotes PHP thinks it's a constant, and looks for one with that particular name. If it doesn't exist, PHP assumes it's a string (while issuing a notice), and that's why your syntax works. Note: When testing it, it seems no notices are issued when the "$array[key]" syntax is used though. The curly brackets are just the correct syntax when using array values of associative arrays inside double quoted strings.
  6. jon23d almost had it; echo "<a href=\"{$row['link']}\">{$row['title']}</a>"; You should also wrap myusername in single quotes (it's not a constant, am I right?), and then wrap the whole session variable in curly brackets. mysql_query("SELECT * FROM locations WHERE owned = '{$_SESSION['myusername']}'")
  7. Well, you are still using intval() when mb_convert_encoding() is available, rendering the function useless.
  8. What? The OP is right, intval() returns 0 on strings/characters that can't be directly casted to an integer. Has got nothing to do with the multibyte functions (correct me if I'm wrong). Simply try to use htmlentities() (code tags f**k up the characters): <?php $str = 'वनमान्छे जोडीलाई सन्तान'; $entities = htmlentities($str, ENT_QUOTES, 'UTF-8'); ?> Remember to use the appropriate second parameter, depending on how quotes are stored in your database. But I agree with Mark in that you should store the data as UTF-8 characters instead. Takes up much less space.
  9. Depends on what the_permalink() returns. From the OP's example it seems it outputs the link.
  10. That won't replace an o at the last position in the string.
  11. You can use a negative lookahead (?!regex), only matching when the regex fails to match: <?php $str = 'Hello world!'; echo preg_replace('~o(?!r)~i', 'a', $str); //Hella world! ?> Remove the i if the search shouldn't be case insensitive.
  12. array_rand() returns a key, so you would have to use $sounds[$rand_sound] instead of $rand_sound.
  13. glob() is less cluttering: <?php $path = '/mypath'; $images = glob($path . '/*.{jpg,jpeg,png,gif}', GLOB_BRACE); natsort($images); echo "Directory Listing of images in $path:<br />"; foreach ($images as $imagepath) { $name = basename($imagepath); echo "<br /><a href=\"$imagepath\">$name</a>"; } ?>
  14. preg_match_all('~\[quote(?:=([^\]]+))?\](.*?)\[/quote\]~is', $str, $matches); If you have any rules for how the username can look, you can change [^\]]+ to the appropriate regex (just ask if you need help). Usernames, if provided, will be stored in the $matches[1] array, and quote contents in the $matches[2] array. And it won't work with nested quotes.
  15. Eh? You don't and can't call javascript in PHP, you simply output it. I realize that's what you probably mean, I'm just making it clear to the OP.
  16. Guess why I split the string on the PHP_EOL constant?
  17. Gotta love those "didn't work" replies without any further details.
  18. I'm guessing you were relying on the register_globals setting being On back then. You access GET variables (the ones set via the URL) with $_GET['name'], so in your case you could simply assign the correct variable to $nid, before using it: $nid = $_GET['nid']; This also applies to POST variables (the ones sent via an HTML form), where the value of a text field named name is accessed with $_POST['name'].
  19. You want to end up with a string again? You can use parse_url() to get the domain: <?php $array = explode(PHP_EOL, $_POST['links']); foreach ($array as &$url) { $url = parse_url($url, PHP_URL_HOST); } unset($url); echo implode(PHP_EOL, $array); ?>
  20. Why?? Megaupload IDs are always 8 chars long AFAIK. I swapped to slashes since the OP are using them in the rest of the patterns (to be less confusing).
  21. get_urls_by_kwd("\"megaupload.com/?d=\" ".$row[1],"/megaupload\.com\/\?d=[0-9a-z]{8}/i",3); I was using ~ as pattern delimiters, and you're using /. Fixed that. The i modifier makes the search case in-sensitive.
  22. <?php if (preg_match('~^[a-z -]{2,}$~iD', $str)) { //the string contains only a-z, A-Z, hyphens and/or spaces, and is at least two chars long } else { //the opposite } ?>
  23. '~(?:http://)?(?:www\.)?megaupload\.com/\?d=[0-9a-z]{8}~i' Assuming the ID consists of a-z, A-Z and/or 0-9, and that it's always 8 in length.
  24. Did you totally overlook my questions?? Guessing: <?php if (preg_match('~^[a-z -]+$~iD', $str)) { //the string contains only a-z, A-Z, hyphens and/or spaces, and is at least one char long } else { //the opposite } ?>
  25. Need more info. Are those chars the only allowed, or do you just want to check if one of them are found in the string? Must the string have a minimum and/or maximum length? Can it consist of e.g. spaces only?
×
×
  • 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.