Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. I'm failing to spot how that jQuery is related to that block of HTML? I see no elements with a class of "clickme".
  2. for this code <?php curl_setopt($ch, CURLOPT_USERAGENT, 'HackAliveCrawler htpp://mysite.com/hackalivecrawler'); echo $_SERVER['HTTP_USER_AGENT']; echo "|"; echo $_SERVER['USER_AGENT']; ?> That's not how it works. As thorpe has just replied, you need to define $ch (look at the cURL examples on the manual), but even then it only sets the user agent for the request you're going to make with cURL.
  3. Think you're missing the point in using single quotes, it's to make writing HTML (with correct double quotes around attribute values) easier. For your example you can just use: var showText='Click here to expand <img src="/images/arrow-down.png" /> '; var hideText='Return to top <img src="/images/arrow-up.png" />';
  4. People using single quotes has been going on a long time, I'd be surprised if a browser weren't able to handle them (IE certainly can). Most likely it's something that page is doing to break out of the frame (perhaps to stop you putting their page within a frame??). I'm guessing "https://www.websites.com/process.php" isn't the actual URL?
  5. What do you mean by multiple values..? So every time you select some text, it inserts them like above (or similar)?
  6. <iframe> does not support any events, according to the w3c standards. "onload" is pretty well supported amongst browsers though.
  7. For a start I'd use single quotes to make it easier on yourself: var showText='Click here to expand <img src="/images/arrow-down.png" style="float:right" alt="" /> '; var hideText='Return to top <img src="/images/arrow-up.png" style="float:right" alt="" />'; Then in the event you need to use a single quote, just escape it with a backslash: var str = 'it\'s that simple!';
  8. var str = '££$%£'; if (str.match(/^[^a-zA-Z0-9]+$/)) { alert("doesn't contain alphanumeric"); }
  9. I believe that'll be the browser over-writing whatever you send. If you're using cURL to crawl the pages as I mentioned before just send it as a cURL option. Edit: Should add I'm only speculating about the browser, I'm not fully sure how that part works.
  10. Sorry, if you're using cURL you'll need to set the cURL option: curl_setopt($ch, CURLOPT_USERAGENT, 'HackAliveCrawler htpp://mysite.com/hackalivecrawler');
  11. I'm guessing you mean with PHP? You can send it as a header: header('User-Agent: HackAliveCrawler htpp://mysite.com/hackalivecrawler');
  12. It looks pretty good, but it's totally unusable from a community point of view. What happens if there was a few thousand posts, and someone wanted to show someone one? There's no way (or obvious way) of linking to them.. Unfortunately that also means Google has no way of indexing them, and so your site fails badly on SEO.
  13. When you say match "</div><div>", do you mean exactly that? What about white space? preg_replace('/(\[css\].*?)<\/div>\s*<div>(.*?\[\/css\])/s', '$1<br />$2', $str); If you don't want it to match white space between the div tags, just remove "\s*".
  14. Oh yeah, was overcomplicating things..
  15. select * from $table ORDER BY rand() LIMIT 9
  16. Probably because you have the query contained in a loop.. while($i < 10) { Why is it within a loop?
  17. And you if run the SQL in a MySQL administrator?
  18. What are you saying yes to?
  19. You most likely have an error in your SQL syntax. Look into mysql_error..
  20. You're saying the query is selecting the exact same record twice? Does this happen if you run the same SQL separately in a MySQL administrator (e.g. PHPMyAdmin)? Edit: by the way mysql_db_query is deprecated.
  21. With setting $b to 0 at the end, you're causing an infinite loop.
  22. I don't know why you'd have duplicate users in that table, but you just need to modify your SQL. Try adding a group by clause: select * from $table GROUP BY username ORDER BY rand()
  23. Thought this was going to be easy when I first looked at it, but decided to find a solution for my own curiosity more than anything. It's ugly, but: $array = array( 'value 1', 'value 1', 'value 1', 'value 2', 'value 2', 'value 2', 'value 3', 'value 3', 'value 4', 'value 5', ); $counts = array_count_values($array); foreach ($counts as $count_key => $count) { if ($count < 3) { foreach ($array as $key => $value) { if ($value == $count_key) { unset($array[$key]); } } } } I wonder if anyone has a better way?
  24. foreach ($_COOKIE as $name => $value) All that does is assign the current element's key ($name) and value ($value) in the array to those variables, then advances the array pointer for the next iteration. "=>" is not a comparison operator, but an assignment operator. You can read more on those in the manual. It's pretty simple to incorporate the key check. Just to check for a single key: if (!empty($_COOKIE)) { foreach ($_COOKIE as $name => $value) { if ($name == 'special_key') { continue; } setcookie($name, $value, time() -1); } } Personally though I'd go with this second option (in future it'd be easier to expand): $special_keys = array('special_key1', 'special_key2'); if (!empty($_COOKIE)) { foreach ($_COOKIE as $name => $value) { if (in_array($name, $special_keys) { continue; } setcookie($name, $value, time() -1); } } Sorry, in_array would be used in this example, not array_key_exists().
×
×
  • 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.