Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

bibby's Achievements


Newbie (1/5)



  1. gotcha, looks like I was thinking it was mysql's inet_aton()
  2. johnny86's would work. At the same time, I was posting: $emailsToSend = array(); foreach( $myarray as $service) { $e = $emails_array[$service]; if($e) $emailsToSend[$service]=$e; } Does this do what you need? What can also do with your checkboxes is create an array in the post using a specific value ( ; the value does not have to be the string 'on' ). <input type="checkbox" name="services[]" value="Landscaping" /> <input type="checkbox" name="services[]" value="Blah" /> That'll post $_POST['services'] as an array instead of a string.
  3. Long answer, sorry.. coupla things. first I'll answer the question, then offer what might be a better solution (though it takes more work). To detect the presence of a comma, you can use strpos or preg_match (and other fxns). strpos returns the position of the first occurrence of a string within a string, which could be 0. This is not to be mistaken for FALSE (return for no match), but in the "last, first" scenario it's probably not applicable. $hasComma = FALSE != strpos($trimmed, ','); # or $hasComma = preg_match('/,/',$trimmed,$m); or, you could just explode on the comma and count the result. $parts = explode(',', $trimmed); $hasComma = count($parts)>1; if there was a comma, and you're ok with assuming the user put in "last, first" (also assuming/checking that count($parts)==2 ), you can flip like so. list( $first, $last ) = $parts; if( $hasComma ) list($last, $first) = array($first, $last); doing any exploding at all, you might want to trim all the parts so that you might reconstruct them in a controlled manner. $parts = array_map("trim", $parts); // I also like to filter empty parts $parts = array_values( array_filter( $parts )); Then your search term can be reconstructed $term = join(' ',array($first, $last)); ---------------- Now, I've gotta say that I don't think you've got an ideal search. What you might want to is break the search term apart (by space, comma, etc) and query an index of individual words. This is how you can rank of "relevance" and offer more results than you would have if the user misspelled their search term (which 5%-15% of users will always do). By "index" I mean a new table containing "terms" and their associative artist_ids. Let's take an example data set of three artists: 1- Johnny Cash 2- Sweep the Leg Johnny 3- Clean Sweep Ignoring "the", our index of unique words is: Johnny Cash Sweep Leg Clean The linking table could look like: _term_|_artist_id_ Johnny | 1 Cash | 1 Sweep | 2 Leg | 2 Johnny | 2 Clean | 3 Sweep | 3 Gather up possible matches for each word, paying special attention to when the same records appear. That should increase their relevance. Misses should decrease the "score". Then present your results in order of score. It's often better to show more results than fewer. Before, a search for 'Sweep Johnny' would net 0 results, but we've all come to expect the search to be more lenient with our brevity. If we searched an index for each word, I'd get all three results, but I'd get exactly what I was looking for on the top. #1 Sweep the Leg Johnny (100% 2/2) #2 Johnny Cash (50% 1/2) #3 Clean Sweep (50% 1/2)
  4. I like sprintf and vsprintf for this -- more separation. Just another option in a sea of many. $q = "UPDATE members SET logfile = '%s admin logged into long2ip(%s)' WHERE username='%s'"; $q = vsprintf($q, array( mysql_real_escape_string($playerlog), $ip, mysql_real_escape_string($player), ));
  5. The best guess that I have as to why the list of arguments provided by __call is an array is a matter on convenience. The arity of __call is always 2 ( http://dictionary.die.net/arity ), __call( string $methodName, array $arguments), but you can call a method that does not exist using zero or more arguments without limitations. Packing them neatly into an array is the only option, since __call is meant to handle any situation where a method that does not exist is called, regardless of how many arguments are given. If you are using the undefined method setFirstName as a proxy for a set method that does exist or pass it onto another object within scope, you can call call_user_func_array to invoke that method using the arguments array as-is. call_user_func_array(array($class, $method), $argArray) Otherwise, you'll just have to deal with your arguments as an array. $foo->methodDoesNotExist( "foo", "bar", "baz" ); // __call picks it up ( __call( $method, $args ) ) (in __call) var_dump( $method, $args ); /* == string "methodDoesNotExist" // $method array(3)( // $args [0] => "foo", [1] => "bar", [2] => "baz" ); */
  6. bibby


    If the page within the iframe is on the same domain as the top page, then it's document.cookie , just as it is on top. If the iframe is points to a different domain, then the browser won't let you. That's cross site scripting, and can be evil.
  7. Sounds like you might want :eq(), http://api.jquery.com/eq-selector/ It filters the selection to the nth selector. $("#table_id tr:eq("); // the 9th row, in this case.
  8. scandir will also have the "files" '.' (here) and '..' (parent directory), be sure to filter those out. The directory will more than likely see its modified time updated when one of its files does. I like is_file for as well, because file_exists() on a directory will be TRUE.
  9. Perhaps you're making it harder than it needs to be. If these images were on your server, you may elect to use a relative path, right? <img src="imgs/blah/some.png"> So when your users enter an image as a full url, your aim is simply to make that the source, no? <img src="http://notyourdomain.com/some.png"> There isn't much to that. Now, if you want to cache local copies of those remote images, that's a better question. Is that what you meant? If so, look at file_get_contents( $url ) and be sure to check that it's really an image and not a malicious script.
  10. That sounds to me like a problem for javascript. In the alert() family, there is confirm() and prompt()
  11. not many (any?) other languages support this, but you can use brackets with a key to push to the "next" available key. $a = array(); $a[] = 1; // key 0 $a[] = 2; // key 1
  12. db backups are a lot easier from the command line ( using mysqldump ) mysqldump -h host -u user -p passwd db > backup.sql
  13. It's possible that the script is running before the form has finished closing ( /form ). IE doesn't much like appending child elements to one that's currently in the process of being written. Try moving the script after /form
  14. You're going to want to add the :checked selector to the one you have. $('[name=type_select]:checked').val() The above will return either 1, 2, 3, or nothing if there is no selection.
  15. Using divs seems a little heavy handed. document.createElement('br') is perfectly reasonable, and exactly what you were initially asking for ("nl2br"). Working example @ http://bbby.org/u/w
  • 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.