Re: [PHP] Matching
On Fri, 2009-01-30 at 21:33 -0500, Eric Butera wrote: On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom Go regular expressions... /tx=([^\]+)/ then do a preg_match with the string using the $matches array argument. $matches[1] should be your value. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching
On Sat, Jan 31, 2009 at 7:32 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-01-30 at 21:33 -0500, Eric Butera wrote: On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom Go regular expressions... /tx=([^\]+)/ then do a preg_match with the string using the $matches array argument. $matches[1] should be your value. Ash www.ashleysheridan.co.uk There really isn't a need to even try to build something like that when something already exists exactly for the purpose. It's well documented too. Plus after this part works, there's probably a good chance we'd be looking for that second variable. =) -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching
On Sat, 2009-01-31 at 08:38 -0500, Eric Butera wrote: On Sat, Jan 31, 2009 at 7:32 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-01-30 at 21:33 -0500, Eric Butera wrote: On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom Go regular expressions... /tx=([^\]+)/ then do a preg_match with the string using the $matches array argument. $matches[1] should be your value. Ash www.ashleysheridan.co.uk There really isn't a need to even try to build something like that when something already exists exactly for the purpose. It's well documented too. Plus after this part works, there's probably a good chance we'd be looking for that second variable. =) -- http://www.voom.me | EFnet: #voom But isn't what you suggest to use only available in PHP5? When possible, I try to build for PHP4, as my own hosting, and others I've seen only support 4, and the old answer of find a better hosting is not always a good solution. Besides, if you need the second part of the URL, just adapt the regular expression a bit. I don't why people seem so afraid of them to be honest. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching
On Sat, Jan 31, 2009 at 9:33 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2009-01-31 at 08:38 -0500, Eric Butera wrote: On Sat, Jan 31, 2009 at 7:32 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-01-30 at 21:33 -0500, Eric Butera wrote: On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom Go regular expressions... /tx=([^\]+)/ then do a preg_match with the string using the $matches array argument. $matches[1] should be your value. Ash www.ashleysheridan.co.uk There really isn't a need to even try to build something like that when something already exists exactly for the purpose. It's well documented too. Plus after this part works, there's probably a good chance we'd be looking for that second variable. =) -- http://www.voom.me | EFnet: #voom But isn't what you suggest to use only available in PHP5? When possible, I try to build for PHP4, as my own hosting, and others I've seen only support 4, and the old answer of find a better hosting is not always a good solution. Besides, if you need the second part of the URL, just adapt the regular expression a bit. I don't why people seem so afraid of them to be honest. Ash www.ashleysheridan.co.uk parse_str (PHP 4, PHP 5) parse_str — Parses the string into variables -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching
Eric Butera wrote: On Sat, Jan 31, 2009 at 9:33 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2009-01-31 at 08:38 -0500, Eric Butera wrote: On Sat, Jan 31, 2009 at 7:32 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-01-30 at 21:33 -0500, Eric Butera wrote: On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom Go regular expressions... /tx=([^\]+)/ then do a preg_match with the string using the $matches array argument. $matches[1] should be your value. Ash www.ashleysheridan.co.uk There really isn't a need to even try to build something like that when something already exists exactly for the purpose. It's well documented too. Plus after this part works, there's probably a good chance we'd be looking for that second variable. =) -- http://www.voom.me | EFnet: #voom But isn't what you suggest to use only available in PHP5? When possible, I try to build for PHP4, as my own hosting, and others I've seen only support 4, and the old answer of find a better hosting is not always a good solution. Besides, if you need the second part of the URL, just adapt the regular expression a bit. I don't why people seem so afraid of them to be honest. Ash www.ashleysheridan.co.uk parse_str (PHP 4, PHP 5) parse_str — Parses the string into variables lol - it's obviously an url guys.. http://php.net/parse_url and http://php.net/parse_str $s = 'your/url/?with=parrams'; $parts = parse_url($s); $arrayOfQueryParams = parse_str($parts['query']); $theBitYouWant = $arrayOfQueryParams['tx']; // output the bit you want echo $theBitYouWant . PHP_EOL; // output all the params print_r($arrayOfQueryParams); regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching
How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron
Re: [PHP] Matching
On Fri, Jan 30, 2009 at 9:28 PM, Ron Piggott ron@actsministries.org wrote: How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron http://us.php.net/parse_str -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Matching
How do I determine the value of tx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951Tst=Completedamt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the Ron I'm sure Eric gave you the answer you needed if your parsing the string in a page. However, if your pulling this as a URL redirect you can use the GET global variable tx... IE: $tx = $_GET['tx']; echo $tx; //8UM53005HH344951T (printed to browser) HTH :) David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching Proper Versions Of PHP and MySQL
Hello All, I'm a newbie. My server just upgraded to PHP version 5.1.2 from php 4.3.11 MySQL currently is v 4.0.27 Q: What is the oldest - best/safest version of mySQL to use with PHP version 5.1.2.? The reason I mentioned the oldest - is because, for legacy clients, I would like to do the minimum upgrade to ensure best compatibility with legacy code ( mySQL and NON php etc.). If it is OK to stay on mySQL version 4.0.27 ... That would be good to know. Q: Is PHP version 5.1.2 - relatively stable version of PHP 5? -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching logins to an old htpasswd file
Hey, I have a old htpasswd file with a lot of logins in this format: test:dGRkPurkuWmW2 (test:test) test1:dGlAW3zdxeAG2 (test1:test1) now I have a login form what takes a POST user and a POST pw... but if you look at my above first example login.. the username and pass are test:test but it gets encoded into test:dGRkPurkuWmW2 so how do I try to match the data I get from the POST pw field when that will come in as normal text? Any example code, links (even a RTFM+URL) would be appreciated. Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Don't get soaked. Take a quick peak at the forecast with theYahoo! Search weather shortcut.
Re: [PHP] Matching logins to an old htpasswd file
Hello Ryan, On 03-03, Ryan A wrote: test:dGRkPurkuWmW2 (test:test) test1:dGlAW3zdxeAG2 (test1:test1) $php -r print crypt('test',base64_encode('test'));; - dGRkPurkuWmW2 $php -r print crypt('test1',base64_encode('test1'));; - dGlAW3zdxeAG2 So compare the password string with the output of crypt with the password as its key and salt argument. (References: http://www.htaccesstools.com/forum/index.php/t/25/ , crypt(3) man page) Remark: Asking users to send their login password via an unencrypted webpage only should be done within secure networks. (Anyone can sniff HTTP, use HTTPS otherwise.) HTH, -- Holger Blasum +49-174-7313590 (cell) GnuPG 1024D/ACDFC3B769DC1ED66B47 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching numbers 1-100
On Sat, February 3, 2007 11:09 am, Wikus Moller wrote: I want to know if anyone can help me with my code which matches a number to a range e.g. 1-15 and echoes an image if the number is in the range. The code would use the if statement and check if a variable for example 5 matches the range like 4-10 and if it does it echoes a certain image. Anyone know which function I should use and what regex I should use? This sounds a heck of a lot like a homework assignment... Oh well. ?php $input = '42'; $number = (int) $input; //make sure it's a number if ($number = 1 and $number = 15) echo an image; This will be problematic if you need to detect '0', since 'a' turns into '0' in the typecast. In that case, you'd want http://php.net/pcre -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching numbers 1-100
Hi. I want to know if anyone can help me with my code which matches a number to a range e.g. 1-15 and echoes an image if the number is in the range. The code would use the if statement and check if a variable for example 5 matches the range like 4-10 and if it does it echoes a certain image. Anyone know which function I should use and what regex I should use? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching numbers 1-100
Hi. I want to know if anyone can help me with my code which matches a number to a range e.g. 1-15 and echoes an image if the number is in the range. The code would use the if statement and check if a variable for example 5 matches the range like 4-10 and if it does it echoes a certain image. Anyone know which function I should use and what regex I should use? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching numbers 1-100
At 5:09 PM + 2/3/07, Wikus Moller wrote: Hi. I want to know if anyone can help me with my code which matches a number to a range e.g. 1-15 and echoes an image if the number is in the range. The code would use the if statement and check if a variable for example 5 matches the range like 4-10 and if it does it echoes a certain image. Anyone know which function I should use and what regex I should use? Thanks Hi: Wasn't this same question just asked by Chilling Lounge Admin? It does seem that similar questions rise at similar times, must be sun spots. In any event, its the same answer -- use a switch. http://us2.php.net/switch hth's tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching Number of Times a Word Occurs...
Im trying to count the number of times a word occurs in a string - is the only way to do this preg_match_all? Russ Jones -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching Number of Times a Word Occurs...
Hello, http://us4.php.net/substr_count Regards, Matthew Fonda Russell P Jones wrote: Im trying to count the number of times a word occurs in a string - is the only way to do this preg_match_all? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching Number of Times a Word Occurs...
substr_count() should be more easy, but limited in functionality. Prathap -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching *exact* string?
hello all I am foreach()ing through an array of ip addresses in a 'ban script' and have the following php code: foreach($ips as $ip) { preg_match(/$ip/, $_SERVER[REMOTE_ADDR]); $ban = TRUE; } This is great, but if 127.0.0 were in the ban list (for example) it would still produce a ban as it partially matches. How can I alter the above so that only *exact* matches are banned? Much thanks! -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Matching *exact* string?
Nick Wilson wrote: How can I alter the above so that only *exact* matches are banned? Using ^ and $ to mark the begin and end of the line. So try this /^$ip\$/ -- Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18) [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger [EMAIL PROTECTED] to get public key) signature.asc Description: OpenPGP digital signature
[PHP] matching search terms
Hi all. I was wondering if any of you have experience with searching through a database for user provided search terms. I was hoping that maybe I could get some insight into how to better approach what I am doing. Are there any great articles or example classes that I could look at? Please let me know! As of right now, my architecture is to have a primary class, Search, which connects to the database, takes search terms, removes junk wordsand suffixes (s, ing, etc.) (both defined by an array). The class runs a query on each word for each field that the class is told to search, and based on the relevance of that field (as supplied to the class), points are awarded to returned items. If they come up again on searches for other words, they get more points. Using that base architecture, I then extend the class (e.g. class Faq extends Search) and define word groups in the subclass. Word groups act to broaden the search words in a thesarus like fashion (when the search term dvd comes up, movie, title, video, etc. are added to the SQL query via OR). This way each subclass can define it's own set of word groups applicable for that usage. The problem I am having is that far too many irrelevant items are coming up. When is my package coming? for example returns all kinds of junk because when is everywhere in a Faq. I am hoping that there is some internet resource that has a variety of tricks and rules to throw into a search architecture, but I am also interested to see if anyone can give me some of their personal experience and expertise. Thanks in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] matching search terms
[snip] I am hoping that there is some internet resource [/snip] Which begs the question, have you STFW? http://www.google.com/search?q=search+functionhl=enlr=ie=UTF-8start= 10sa=N -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] matching system - anyone seen any?
I wonder if anyone have come across a script/system that already has this feature, else I would need to do it all over again. The scenario is this : I want people to select the movies they have seen and rate them 1/10. Movies not available in the polling system they can add, and rate them. This way the database is constantly growing, and ratings are constantly added. You can rate as many films you want, or noen if you like. Then, after you have rated you can match your ratings to find other people that match your selections. More like matching a profile really. There would be some sort of system inside here which could build a form of profile based on your ratings, and then compare theese profiles. I havnt really started planning how this would work, or should work, but first mainly if anyone has seen such a system around. Looking for existing wheels... :D -- Kim Steinhaug - There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. - www.steinhaug.com - www.easywebshop.no - www.easycms.no www.webkitpro.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] matching certain values
Im trying to match some words on the value that i have impost on php. But i dont know why it doesnt seem to catch some certain fields. if ($HTTP_USER_AGENT === 'MSIE ') I know something is wrong :( - Louie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] matching certain values
On Thursday 18 September 2003 15:55, Louie Miranda wrote: Im trying to match some words on the value that i have impost on php. But i dont know why it doesnt seem to catch some certain fields. if ($HTTP_USER_AGENT === 'MSIE ') I know something is wrong :( Did you *try* finding out what is wrong? Simple things like echo $HTTP_USER_AGENT to see what it really contains? And if you're only matching part of a string you should be using things like strpos() or preg_match() etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A straw vote only shows which way the hot air blows. -- O'Henry */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] matching certain values
thanks for the reference. strpos will be good for my problem. - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 18, 2003 4:11 PM Subject: Re: [PHP] matching certain values On Thursday 18 September 2003 15:55, Louie Miranda wrote: Im trying to match some words on the value that i have impost on php. But i dont know why it doesnt seem to catch some certain fields. if ($HTTP_USER_AGENT === 'MSIE ') I know something is wrong :( Did you *try* finding out what is wrong? Simple things like echo $HTTP_USER_AGENT to see what it really contains? And if you're only matching part of a string you should be using things like strpos() or preg_match() etc. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A straw vote only shows which way the hot air blows. -- O'Henry */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Matching titles from distinct data sources
Hello Does anyone know of an algorithm or program for matching pieces of text (such as film titles) that are conceptually the same, but which may be written/spelled differently? eg. I need something which will identify a (likely to be) the same: The Matrix Reloaded Matrix Reloaded, The Matrix Reloaded The Matrix: Reloaded etc. Thanks James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] matching two form fields function?
I feel bad about asking a question like this, but I've spent quite a bit of time trying to track down what should be a simple answer and, no luck. Anyway... I'm trying to create a simple function that will match two form fields against each other, e.g. Email equals Repeat Email. The following function seems to work, however, I'm a little uncomfortable because I don't understand it. Specifically, I don't understand why returning $str1 by itself (or $str2 by itself) makes it work. - /* checks two fields against each other to make sure they match and if they don't match it throws an error message into the $err_text array */ function CheckMatch($str1, $str2, $name) { global $err_text; $match = ($str1 == $str2); if ($match != true) { $err_text[] = $name must match.; } return $str1; } - Any help is appreciated! Thanks! Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] matching two form fields function?
Tis a tad easier than that. function match_str($str1, $str2) { if ($str1 == $str2) return true; else return false; } // If the fields don't match exit with error. if (!match_str($field1, $field2)) { echo The fields must match.; exit; } -Kevin - Original Message - From: Jeff Field [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 23, 2002 2:09 PM Subject: [PHP] matching two form fields function? I feel bad about asking a question like this, but I've spent quite a bit of time trying to track down what should be a simple answer and, no luck. Anyway... I'm trying to create a simple function that will match two form fields against each other, e.g. Email equals Repeat Email. The following function seems to work, however, I'm a little uncomfortable because I don't understand it. Specifically, I don't understand why returning $str1 by itself (or $str2 by itself) makes it work. - /* checks two fields against each other to make sure they match and if they don't match it throws an error message into the $err_text array */ function CheckMatch($str1, $str2, $name) { global $err_text; $match = ($str1 == $str2); if ($match != true) { $err_text[] = $name must match.; } return $str1; } - Any help is appreciated! Thanks! Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] matching two form fields function?
Also make sure you trim() the input variables before your comparison... 2cents... /dkm - Original Message - From: Kevin Stone [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 23, 2002 4:30 PM Subject: Re: [PHP] matching two form fields function? Tis a tad easier than that. function match_str($str1, $str2) { if ($str1 == $str2) return true; else return false; } // If the fields don't match exit with error. if (!match_str($field1, $field2)) { echo The fields must match.; exit; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] matching user to tables
Hello All, I written a script(sessions) that authenticates a user and passes that information on to a menu. Then menu displays according to the users permission level. The thing works with several table joins ETC. What I need to do in the next step is to assign the menu and certain tables to a matching user. Does anyone know of a tutorial or decent document on how to go about doing this. TIA Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Matching phrases in search engine
Hi. I´m trying to develop a search engine where users could search not only individual words, but also phrases enclosed by , but I´m having trouble to build the function to recognize each phrase and individual word from a variable sent with html form. Did anybody make something like this? Can you help me in this point? Thank you in advance. Josi
Re: [PHP] Matching strings in a flat/text file?
Nick Richardson wrote: ... Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end ... Try this little code snippet: ? $filename = 'cars.data'; $car = $HTTP_GET_VARS['car']; if ($car != '') { $file = file($filename); if (is_array($file)) { $read = FALSE; foreach ($file as $f) { if (!$read ereg('^##'.$car, $f)) $read = TRUE; elseif ($read ereg('^##end', $f)) { $read = FALSE; break; } elseif ($read) $content .= $f; } } } echo content=$contentbr; ? Hope this helps. :) -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
SV: [PHP] Matching strings in a flat/text file?
Why not use RegEx? I'm doing a similar search with RegEx. Makes the code much shorter. Anders Nawroth www.nawroth.com - Ursprungligt meddelande - Från: Jack Dempsey [EMAIL PROTECTED] Till: [EMAIL PROTECTED]; Nick Richardson [EMAIL PROTECTED] Skickat: den 23 oktober 2001 07:20 Ämne: RE: [PHP] Matching strings in a flat/text file? lots of ideas nick, but can you use a database? MySQL is free and i've found its almost always better to use databases when you can... if you can't, you could do something like this: 1. find the pos of the string you need using strpos 2. find the pos of the ending delimiter 3. substr from the first pos to the end (you'll need to add/subtract some strlen's to slice off the delimiters as well... jack -Original Message- From: Nick Richardson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 23, 2001 1:10 AM To: [EMAIL PROTECTED] Subject: [PHP] Matching strings in a flat/text file? Hey everyone, Anyone out there know how i could do this: I have a client who is an import car tuner. They would like to feature the cars they work on in their website. Instead of creating a new .html or .php file for every car they add to include the background setup, and the general content (type of car, owner, etc...) i want to put the information in to text file and search for it in there. So that's where i need help. I want to be able to put the info into a text file and pass the string to search for through the URL, then match everything between that line and an ending line in the text file, and print that out to the browser. Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end Any ideas on how i can do this??? //Nick Richardson [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Matching strings in a flat/text file?
On Mon, 22 Oct 2001 22:09:56 -0700, Nick Richardson wrote: Hey everyone, Anyone out there know how i could do this: I have a client who is an import car tuner. They would like to feature the cars they work on in their website. Instead of creating a new .html or .php file for every car they add to include the background setup, and the general content (type of car, owner, etc...) i want to put the information in to text file and search for it in there. So that's where i need help. I want to be able to put the info into a text file and pass the string to search for through the URL, then match everything between that line and an ending line in the text file, and print that out to the browser. Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end Any ideas on how i can do this??? the easiest way would be with sed: $data=`sed -n '/##civic_si/,/##end/p' $filename` -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Matching strings in a flat/text file?
Hey everyone, Anyone out there know how i could do this: I have a client who is an import car tuner. They would like to feature the cars they work on in their website. Instead of creating a new .html or .php file for every car they add to include the background setup, and the general content (type of car, owner, etc...) i want to put the information in to text file and search for it in there. So that's where i need help. I want to be able to put the info into a text file and pass the string to search for through the URL, then match everything between that line and an ending line in the text file, and print that out to the browser. Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end Any ideas on how i can do this??? //Nick Richardson [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Matching strings in a flat/text file?
lots of ideas nick, but can you use a database? MySQL is free and i've found its almost always better to use databases when you can... if you can't, you could do something like this: 1. find the pos of the string you need using strpos 2. find the pos of the ending delimiter 3. substr from the first pos to the end (you'll need to add/subtract some strlen's to slice off the delimiters as well... jack -Original Message- From: Nick Richardson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 23, 2001 1:10 AM To: [EMAIL PROTECTED] Subject: [PHP] Matching strings in a flat/text file? Hey everyone, Anyone out there know how i could do this: I have a client who is an import car tuner. They would like to feature the cars they work on in their website. Instead of creating a new .html or .php file for every car they add to include the background setup, and the general content (type of car, owner, etc...) i want to put the information in to text file and search for it in there. So that's where i need help. I want to be able to put the info into a text file and pass the string to search for through the URL, then match everything between that line and an ending line in the text file, and print that out to the browser. Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end Any ideas on how i can do this??? //Nick Richardson [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Matching strings in a flat/text file?
Jack, thanks for the response: I can use a database if really really needed. The main reason for wanting to use a flat file is for ease of update from the client's side. They are not technical in the least, and this will save me from having to update a database everytime. Although i guess i could write a front end to let them add stuff to the database... but i'm lazy like that ;). To do the 3 things you suggested, can you give me a code snippet to do that? //Nick -Original Message- From: Jack Dempsey [mailto:[EMAIL PROTECTED]] Sent: Monday, October 22, 2001 10:20 PM To: [EMAIL PROTECTED]; Nick Richardson Subject: RE: [PHP] Matching strings in a flat/text file? lots of ideas nick, but can you use a database? MySQL is free and i've found its almost always better to use databases when you can... if you can't, you could do something like this: 1. find the pos of the string you need using strpos 2. find the pos of the ending delimiter 3. substr from the first pos to the end (you'll need to add/subtract some strlen's to slice off the delimiters as well... jack -Original Message- From: Nick Richardson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 23, 2001 1:10 AM To: [EMAIL PROTECTED] Subject: [PHP] Matching strings in a flat/text file? Hey everyone, Anyone out there know how i could do this: I have a client who is an import car tuner. They would like to feature the cars they work on in their website. Instead of creating a new .html or .php file for every car they add to include the background setup, and the general content (type of car, owner, etc...) i want to put the information in to text file and search for it in there. So that's where i need help. I want to be able to put the info into a text file and pass the string to search for through the URL, then match everything between that line and an ending line in the text file, and print that out to the browser. Example: I want to pass a string using the URL (blah.php?car=civic_si) then search for ##civic_si in the text file, and print everything until it finds ##end. So the text file will look like this: ##civic_si This is my content, blah blah ##end ##nissan This is more content... yadda yadda ##end Any ideas on how i can do this??? //Nick Richardson [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Matching Question
On Sat, 4 Aug 2001 12:40:42 -0500, Jeff Oien ([EMAIL PROTECTED]) wrote: After a sign up page I want to check if someone is already entered into a database. The First Name, Last Name and Address all have to match exactly in order for it to be considered a duplicate. However this isn't doing what I want. I get the Error produced if the Address matches but the name doesn't. Not sure what I'm doing wrong. Thanks. Jeff Oien you're going about this the wrong way. try it like this: $result=mysql_query(select * from table where first='$first' and last='$last' and address='$address'); if(mysql_num_rows($result)){ // error code } you want to keep the result sets that mysql gives back as small as possible because they take up tons of resources. while ($row = mysql_fetch_array($result)) { $First_Name = $row['First_Name']; $Last_Name = $row['Last_Name']; $Address = $row['Address']; if (($M_First_Name || $F_First_Name == $First_Name) ($M_Last_Name || $F_Last_Name == $Last_Name) ($Address1 == $Address)) { echo htmlheadtitleError/title/head body bgcolor=\#FF\ text=\#00\ link=\#ff\ vlink=\#660099\ h3Error/h3 etc... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: php-list- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Matching Question
Thank you. That worked and I'm sure will have made it work a lot faster later on when there is a lot of data in the database. Jeff Oien On Sat, 4 Aug 2001 12:40:42 -0500, Jeff Oien ([EMAIL PROTECTED]) wrote: After a sign up page I want to check if someone is already entered into a database. The First Name, Last Name and Address all have to match exactly in order for it to be considered a duplicate. However this isn't doing what I want. I get the Error produced if the Address matches but the name doesn't. Not sure what I'm doing wrong. Thanks. Jeff Oien you're going about this the wrong way. try it like this: $result=mysql_query(select * from table where first='$first' and last='$last' and address='$address'); if(mysql_num_rows($result)){ // error code } you want to keep the result sets that mysql gives back as small as possible because they take up tons of resources. while ($row = mysql_fetch_array($result)) { $First_Name = $row['First_Name']; $Last_Name = $row['Last_Name']; $Address = $row['Address']; if (($M_First_Name || $F_First_Name == $First_Name) ($M_Last_Name || $F_Last_Name == $Last_Name) ($Address1 == $Address)) { echo htmlheadtitleError/title/head body bgcolor=\#FF\ text=\#00\ link=\#ff\ vlink=\#660099\ h3Error/h3 etc... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: php-list- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Matching Question
ok, if i understand you correctly, you're taking data from a form and want to check that it is not already in the database, right? then why don't you include the submitted vars in the query like this: $sql = SELECT First_Name, Last_Name, Address FROM $table_name WHERE (Family_Position = 'H' or Family_Position = 'S') and first_name = '$form_First_Name' and last_name='$form_last_name' and address='$form_address'; $result = @mysql_query($sql,$connection) or die( Couldn't execute query.); $number_of_matches = mysql_num_rows($result); if ($number_of_matches 0) {print bla bla; else{ //submitted info is ok and can be inserted } please correct me if i missunderstood your question regards At 21:52 04/08/01, you wrote: Here is the query part: $sql = SELECT First_Name, Last_Name, Address FROM $table_name WHERE Family_Position = 'H' or Family_Position = 'S'; //$result = @mysql_query($sql,$connection) or die( Couldn't execute query.); if(! $result = mysql_query($sql,$connection)) { print(ERROR .mysql_errno().: .mysql_error().br\n$sqlbr\n); } whta does your query look like? At 19:40 04/08/01, you wrote: After a sign up page I want to check if someone is already entered into a database. The First Name, Last Name and Address all have to match exactly in order for it to be considered a duplicate. However this isn't doing what I want. I get the Error produced if the Address matches but the name doesn't. Not sure what I'm doing wrong. Thanks. Jeff Oien while ($row = mysql_fetch_array($result)) { $First_Name = $row['First_Name']; $Last_Name = $row['Last_Name']; $Address = $row['Address']; if (($M_First_Name || $F_First_Name == $First_Name) ($M_Last_Name || $F_Last_Name == $Last_Name) ($Address1 == $Address)) { echo htmlheadtitleError/title/head body bgcolor=\#FF\ text=\#00\ link=\#ff\ vlink=\#660099\ h3Error/h3 etc... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Matching irregular cases
I think this'll be an easy one for you fellas... I'm writing a search function for my site. The code to search the mysql db's are in place and working but here's the problem. For any matches that are displayed, I want to change the search query so it stands out in the result list. I'm just using... ereg_replace($search_query, "b$search_query/b", $row[6]); ...at the moment, but it wont match results where the case doesn't match. Ie if the search query is "blah", the mysql search will return both "blah" and "Blah" but the ereg_replace will only add the b tag to the "blah" result, not the "Blah" one. Thanks in advance. Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Matching irregular cases
(/me smacks head) thanks, completely forgot about that. Steve -Original Message- From: Robert Collins [mailto:[EMAIL PROTECTED]] Sent: 17 January 2001 15:57 To: 'jalist'; [EMAIL PROTECTED] Subject: RE: [PHP] Matching irregular cases Steve, Try the ereg_replace()somthing like this: eregi_replace($search_query, "b$search_query/b", $row[6]); Robert W. Collins Web Developer II Insight / TC Computers www.insight.com www.tccomputers.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Matching irregular cases
displayed, I want to change the search query so it stands out in the result list. I'm just using... ereg_replace($search_query, "b$search_query/b", $row[6]); ...at the moment, but it wont match results where the case doesn't match. Try eregi_replace... php.net/eregi_replace --Toby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]