Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Well...in general I agree with that concern but IMO Google has a lot of money and power (and therefore lots of druish princesses) and will not be going anywhere...ever. They could have just taken that 1.65bn and literally used it as toilet paper and it wouldn't really hurt them, other than possibly inflaming some hemorrhoids. From that PoV, even if YouTube did not bring forth untold riches...no real big loss for them. That doesn't mean you should make stupid business decisions just because you have more money than you know what to do with...but just sayin'...I think people have been/are over-reacting about it. I don't know all the ins-and-outs of what Google does to make money off of YouTube but I can think of a whole lot of things they can do to make plenty of money off it, and I'm just some random nobody, so I'm quite sure Google will inevitably implement or at least test market virtually anything I have thought of and then some, and be just fine.
  2. For ranges, the function will only work for single character ranges. If you try to pass "can-ciz" it will just look for that literal string. So from attempts: $subRanges = "can-ciz"; This will look to see if the $search string starts with the literal string 'can-ciz' so for instance $search = "can-cizblahblah" would return true $subRanges = array('c','an-iz'); This will look to see that $search starts with a "c" followed by literal "an-iz" so if $search = "can-izblahblah" it would return true. In order to look for everything that alphabetically falls between Can* to Ciz* you have to pass it like this: $subRanges = array("c","a-i","n-z");
  3. Not really directly relevant to topic, but IMO for YouTube specifically, people "went crazy" not so much because of the price tag, but because of who bought it and what that would mean to YouTube's future as a dominant online video sharing community.
  4. er...? are you referring to doing : $subRanges = array('a-z','abc','z'); $search = 'aabcd'; echo isMatch($subRanges,$search); // 0 (false) Is that what you are referring to? If so, then it doesn't matter what variable you pass to isMatched(). You can do it as that or $range = array('a-z','abc','z'); $search = 'aabcd'; echo isMatch($range,$search); // 0 (false) or echo isMatch('a','abc'); // 0 (false) or echo isMatch($someOtherVar,$randomVariable); // 0 (false) the function itself internally matches 1st argument with $subRanges, 2nd argument with $search
  5. The only thing that is supposed to be in the foreach loop is that first line with the ternary operation. Since you don't need {..} wrapped around just one line of code in a loop (or condition), I left it out. With {...} it would look like this: function isMatch($subRanges,$search) { if (!is_array($subRanges)) $subRanges = array($subRanges); foreach ($subRanges as $k => $v) { $subRanges[$k] = (preg_match('~^[a-z]-[a-z]$~i',$v)) ? '['.$v.']' : preg_quote($v); } $subRanges = implode('',$subRanges); return preg_match('~^'.$subRanges.'~i',$search); } // end isMatch
  6. Okay modified function: /** * @param string $subRanges Array of range of letters to look for after $base. Should be "a-r","b-x" etc... * @param string $search The string to be checked */ function isMatch($subRanges,$search) { if (!is_array($subRanges)) $subRanges = array($subRanges); foreach ($subRanges as $k => $v) $subRanges[$k] = (preg_match('~^[a-z]-[a-z]$~i',$v)) ? '['.$v.']' : preg_quote($v); $subRanges = implode('',$subRanges); return preg_match('~^'.$subRanges.'~i',$search); } // end isMatch Okay basically I combined $base and $range into a single argument $subRanges, and you can pass a single string or an array of strings as the first argument. Passing a single string like 'a' or 'abc' will make it look for that exact string. Passing a hyphenated string like 'a-z' will make it look for a range. You can mix and match passing a range or literal string for each element in $subRanges. Examples: Match if $search starts with 'a' $range = 'a'; $search = 'apple'; echo isMatch($range,$search); // 1 (true) Match if $search starts with 'aa' $range = 'aa'; $search = 'aardvark'; echo isMatch($range,$search); // 1 (true) Match if $search starts with 'a', followed by 'a' (effectively same thing as previous example) $range = array('a','a'); $search = 'aardvark'; echo isMatch($range,$search); // 1 (true) Match if $search starts with 'a', followed by 'b' $range = array('a','b'); $search = 'about'; echo isMatch($range,$search); // 1 (true) Match if $search starts with 'a', followed by 'a' or 'b' $range = array('a','a-b'); $search = 'about'; echo isMatch($range,$search); // 1 (true) Match if $search starts with any letter, followed by 'a' or 'b', followed by any letter between 'a' and 'o' (inclusive) $range = array('a-z','a-b','a-o'); $search = 'about'; echo isMatch($range,$search); // 1 (true) Match if $search starts with any letter, followed by 'abc', followed by 'z' $range = array('a-z','abc','z'); $search = 'aabcd'; echo isMatch($range,$search); // 0 (false) Match if $search starts with any letter, followed by 'abc', followed by any letter $range = array('a-z','abc','a-z'); $search = 'aabc'; echo isMatch($range,$search); // 0 (false)
  7. edit: reposting soon
  8. you have delimiters and modifiers in each of your $birth...(and $years) variables, treating them as individual patterns, but then put them all together in $match and treat it as a single pattern. You need to remove the delimiters and modifiers from those variables and only have the delimiter and modifier appear once, wrapped around the whole pattern. Also, your $match variable...you need to wrap that entire thing in quotes...the way you have it now, php attempts to parse that as a mathematical expression. You should have seen from your own echo $match that something was funky...
  9. Thanks for posting a thank you post Sally!
  10. I believe he was referring to "thank you" posts in general, not your OP in particular.
  11. super simple example: <?php if ($_POST) { if ($_POST['from']&&$_POST['subject']&&$_POST['message']) { $to = 'your email address here'; $redirect = 'url to redirect here'; mail ($to, $_POST['from'] , $_POST['message']) ; header('Location: '.$redirect); exit(); } else { echo "you need to fill out all of the fields in the form!</br>"; } } ?> <form name='contact' method='post' action=''> From: <input type='text' name='from' /><br/> Subject: <input type='text name='subject' /><br/> Message: <textarea name='message' cols='20 rows='10'></textarea><br/> <input type='submit' name='submit' value='email!' /> </form>
  12. well I'm not a sql expert but I think maybe something like this should work...(you might wanna ask in the sql forum) SELECT * FROM questions WHERE question_id NOT IN (SELECT question_id FROM assignments_questions WHERE author_id = '$user_id')
  13. Okay, so make a new multi-dim array ($result) with all $questions that do not appear in $assignment_questions: foreach ($assignment_questions as $aq) { $aq_ids[] = $aq['question_id']; } foreach ($questions as $q) { if (!in_array($q['question_id'],$aq_ids)) { $result[] = $q; } } Random question though...are these arrays a result of a db query? I'm thinking it would probably be easier/better for you to grab this from a db query (as a new query or adding to existing query)
  14. can you post an example of your arrays? like... echo "<pre>"; print_r($questions); print_r($assignment_questions);
  15. Is there a reason you don't want to use set_time_limit()? Is it because you are afraid you won't set it high enough? Because if you just pass it 0 as the time limit, that's the same as saying "no time limit".
  16. A server is not going to be running graphic-heavy applications like Windows or games (as in graphic processing of games) so it doesn't really need the large amount of RAM, processing power, etc.. that a client computer requires. Having said that... as with any computer...it depends on how much traffic you are expecting, what all your site will be doing, etc...if it is going to be for personal use, then that *probably* will be more than enough for your needs. Would help if you gave more details about what you're actually wanting to do with it though.
  17. /** * @param string $base The base string to check for at the beginning of $search * @param string $range The range of letters to look for after $base. Should be "a-r","b-x" etc... * @param string $search The string to be checked */ function isMatch($base,$range,$search) { $base = preg_quote($base); if (!preg_match('~^[a-z]-[a-z]$~i',$range)) $range = 'a-z'; return preg_match('~^'.$base.'['.$range.']~i',$search); } example: $list = array('apple','orange','aardvark','aluminum','area','addict','banana','yellow','zoo','oral','oracle'); $find = "A"; $range = "a-k"; foreach($list as $search) { echo $search . " : "; if (isMatch($find,$range,$search)) { echo "matched"; } else { echo "not matched"; } echo "<br/>"; } output: apple : not matched orange : not matched aardvark : matched aluminum : not matched area : not matched addict : matched banana : not matched yellow : not matched zoo : not matched oral : not matched oracle : not matched
  18. what do you mean? Are you saying you want all "/xyz/somePage.html" links to have target="_top" attribute? Sure, you can do this with javascript. Easiest way is with a library like jQuery: <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js'></script> <script type='text/javascript'> $(document).ready(function() { // change /xyz/ to your directory $("a[href*='/xyz/']").attr('target','_top'); }); </script> You can do something similar in Prototype or some other js library if you are already using one on your site (syntax will be slightly different). Or if you don't want to use a framework, you can do it with pure js with getElementsByTagName(), a for loop, getAttribute(), an if condition, and setAttribute(). Or you could of course just hardcode target="_top" in all your relative link tags...
  19. okay well then you still need to post an example of what the users.txt file looks like so compare it to what you are trying to do to parse it.
  20. can't really help without showing us example of what your users.txt file looks like (the format of the contents) but anyways, this is a terrible way of doing a login system. For starters, what prevents a user from being able to go directly to www.yoursite.com/users.txt and getting everybody's login info? You should be storing this information in a database. 2nd, you should be encrypting the password (which based on your posted code, you aren't). There are a million login/authentication tutorials out there, I suggest you scrap this, pick one and follow it.
  21. okay prev post was the query...that error sounds like you aren't selecting a db when you make a connection...in your code, somewhere before the query, after you use mysql_connect() to connect to connect to mysql, you should be using mysql_select_db to select which db your table is in
  22. select * from pcm where sex='1' order by rand() limit 1
  23. <?php // image and thumb paths $img_dir = "images/photographs/"; $thumb_path = "images/photographs/thumbs/"; // get first $amount of images from dir $amount=3; $images = array_map('basename',glob($img_dir . "*.jpg")); $images = array_slice($images,0,$amount); // create and output thumbs foreach ($images as $image) { $size = getimagesize($img_dir.$image); $width = $size['0']; $height = $size['1']; $nwidth = round($width/20); $nheight = round($height/20); $img_thumb = imagecreatefromjpeg($img_dir.$image); $resized = imagecreatetruecolor($nwidth, $nheight); imagecopyresampled($resized, $img_thumb, 0, 0, 0, 0, $nwidth, $nheight, $width, $height); imagejpeg($resized, $thumb_path.$image); echo "<img src='{$thumb_path.$image}' height='{$nheight}' width='{$nwidth}'/>"; } // end foreach ?>
  24. you can obfuscate it. Or you can post details about what it does and maybe we can help you come up with a server-side solution instead.
  25. There is one note in the manual that mentions rearranging order of calls to curl_setopt() for posting data, but other than that, afaik it doesn't matter which order you put that stuff in.
×
×
  • 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.