php-general Digest 13 Jul 2008 12:31:32 -0000 Issue 5566
php-general Digest 13 Jul 2008 12:31:32 - Issue 5566 Topics (messages 276709 through 276721): Re: IPv6 validation 276709 by: Robert Cummings 276717 by: Per Jessen 276718 by: Kevin Waterson Re: Most popular per month 276710 by: Wolf 276712 by: Brady Mitchell PDO Question. Number of rows returned 276711 by: Stephen 276716 by: Kevin Waterson Saving loading time at counting rows 276713 by: Joep Roebroek 276714 by: tedd 276715 by: Robert Cummings 276719 by: Colin Guthrie 276720 by: Per Jessen Re: case and accent - insensitive regular expression? 276721 by: Andrew Ballard Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- On Sun, 2008-07-13 at 07:02 +1000, Kevin Waterson wrote: This one time, at band camp, Yeti [EMAIL PROTECTED] wrote: It will still take some time until every provider has PHP5 running, at least where I am from. I have many customers who want me to get their sites running on some cheap webspace they got along with their internet connection. Then you have to tell them it won't work because of some problem with the versions. I would love to write code for PHP5+ only.This is a terrible excuse for using PHP 4. Today, July 13, marks 4 years since the release of PHP 5.0. _4 YEARS_ to move applications and code to PHP5. Its either apathy or incometence. I think apathy... for those who don't give a damn about OOP or the advanced OOP features, PHP5 brought little to the table while often requiring work to get your code there. Then followed multiple versions each with their own quirks all the while tightening a noose of OOP correctness around the developer who didn't care about some purists OOP philosophies. Finally, and this isn't particularly true anymore, PHP5 was much slower in earlier versions. And yes, I've modified my own code as things have progressed, but I certainly do have clients that didn't want me wasting their money converting their code-base (not originally written by me) to PHP5. And yes, I've seen terrible things in the code that PHP5 certainly did break. And again, yes, some of this was due to poor coding on the original developer's part... but hey, it DID work in PHP4. By forcing an end of life, PHP did a favour to all those developers who couldn't really make the case to their bosses or clients by forcing it upon them. The issue became much more salient at that point. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- Kevin Waterson wrote: This one time, at band camp, Yeti [EMAIL PROTECTED] wrote: It will still take some time until every provider has PHP5 running, at least where I am from. I have many customers who want me to get their sites running on some cheap webspace they got along with their internet connection. Then you have to tell them it won't work because of some problem with the versions. I would love to write code for PHP5+ only.This is a terrible excuse for using PHP 4. Today, July 13, marks 4 years since the release of PHP 5.0. _4 YEARS_ to move applications and code to PHP5. Its either apathy or incometence. No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. Besides, the migration path of php4-5 is not always easy - code may have to be rewritten, other code may not work at all etc. I have two applications that can only run on php 4.3.8 due to a regression of the setlocale() function in later versions. /Per Jessen, Zürich ---End Message--- ---BeginMessage--- This one time, at band camp, Per Jessen [EMAIL PROTECTED] wrote: No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. 4 years its been, thats incompetence. Kevin ---End Message--- ---BeginMessage--- snip .. . $perc50=(img50 int)/$total; You can do it per day, per month, per year, per 28 days, per PMS cycle, per anything you want provided you have the data to do it. /snip :) this is the part where i am a bit confused actually, can you give me one or two examples and i'll work from there? What you have to do is get all the pictures viewed for a specific day/time frame (you said this was all tracked in a DB anyways) and then add up all the totals and perform the same calculations using the views all added over the days all added. $img1=img1 int day1 +img1 int day2 +img1 int day3 img1 int day30 $total= img1 int day1 +img2 int day 1+img3 int day1 +...img50 int day30 $img1perc= $img1/$total ---End Message--- ---BeginMessage--- On Jul 11, 2008, at 555PM,
php-general Digest 14 Jul 2008 04:21:10 -0000 Issue 5567
php-general Digest 14 Jul 2008 04:21:10 - Issue 5567 Topics (messages 276722 through 276739): Re: case and accent - insensitive regular expression? 276722 by: tedd Shared Authentication Scheme - the reason for the Redirect and POST mailing 276723 by: Alex Chamberlain 276725 by: Colin Guthrie 276727 by: Alex Chamberlain Re: Most popular per month 276724 by: Ryan S Re: PDO Question. Number of rows returned 276726 by: Stephen 276729 by: Bastien Koert 276731 by: Stephen 276732 by: Bastien Koert Re: Saving loading time at counting rows 276728 by: Eric Butera 276733 by: Joep Roebroek Re: scalable web gallery 276730 by: paragasu string comparison 276734 by: Sudhakar 276736 by: Robert Cummings 276737 by: dg Re: IPv6 validation 276735 by: Robert Cummings 276738 by: Per Jessen Freelance PHP development in India 276739 by: Denis L. Menezes Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- At 8:31 AM -0400 7/13/08, Andrew Ballard wrote: On Sat, Jul 12, 2008 at 10:29 AM, tedd [EMAIL PROTECTED] wrote: At 9:36 AM +0200 7/12/08, Giulio Mastrosanti wrote: Hi, I have a php page that asks user for a key ( or a list of keys ) and then shows a list of items matching the query. every item in the list shows its data, and the list of keys it has ( a list of comma-separated words ) I would like to higlight, in the list of keys shown for every item, the words matching the query, this can be easily achieved with a search and replace, for every search word, i search it in the key list and replace it adding a style tag to higlight it such as for example to have it in red color: if ( @stripos($keylist,$keysearch!== false ) { $keylist = str_ireplace($keysearch,'span style=color: #FF'.$keysearch.'/span',$keylist); } but i have some problem with accented characters: i have mysql with character encoding utf8, and all the php pages are declared as utf8 mysql in configured to perform queries in a case and accent insensitive way. this mean that if you search for the word 'cafe', you have returned rows that contains in the keyword list 'cafe', but also 'café' with the accent. ( I think it has to do with 'collation' settings, but I'm not investigating at the moment because it is OK for me the way it works ). now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa. hope the problem is clear and well-explained in english, thank you for any tip, Giulio Giulio: Three things: 1. Your English is fine. 2. Try using mb_ereg_replace() http://www.php.net/mb_ereg_replace Place the accents you want to change in that and change them to whatever you want. 3. Change: span style=color: #FF'.$keysearch.'/span' to span class=keysearch'.$keysearch.'/span' and add .keysearch { color: #FF; } to your css. Cheers, tedd I may be mistaken (and if I am, then just ignore this as ignorant rambling), but I don't think he's wanting to replace the accented characters in the original string. I think he's just wanting the pattern to find all variations of the same string and highlight them without changing them. For example, his last paragraph would look like this: [quote] now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'span class=keysearchcafe/span' in a string also if it is 'span class=keysearchcafé/span', or 'span class=keysearchCAFÉ/span', or 'span class=keysearchCAFE/span', and vice-versa. [/quote] The best I can think of right now is something like this: ?php function highlight_search_terms($word, $string) { $search = preg_quote($word); $search = str_replace('a', '[aàáâãäå]', $search); $search = str_replace('e', '[eèéêë]', $search); /* repeat for each possible accented character */ return preg_replace('/\b' . $search . '\b/i', 'span class=keysearch$0/span', $string); } $string = now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa.; echo highlight_search_terms('cafe', $string); ? Andrew Andrew: You may be right -- it's ambiguous now that I review it again. He does say search and replace but I'm not sure
Re: [PHP] IPv6 validation
Kevin Waterson wrote: This one time, at band camp, Yeti [EMAIL PROTECTED] wrote: It will still take some time until every provider has PHP5 running, at least where I am from. I have many customers who want me to get their sites running on some cheap webspace they got along with their internet connection. Then you have to tell them it won't work because of some problem with the versions. I would love to write code for PHP5+ only.This is a terrible excuse for using PHP 4. Today, July 13, marks 4 years since the release of PHP 5.0. _4 YEARS_ to move applications and code to PHP5. Its either apathy or incometence. No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. Besides, the migration path of php4-5 is not always easy - code may have to be rewritten, other code may not work at all etc. I have two applications that can only run on php 4.3.8 due to a regression of the setlocale() function in later versions. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IPv6 validation
This one time, at band camp, Per Jessen [EMAIL PROTECTED] wrote: No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. 4 years its been, thats incompetence. Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Saving loading time at counting rows
Joep Roebroek wrote: I had this question, which I didn't really know where to ask, so I thought to begin at this mailing list. Very basicly said, I count the rows of a table which had approx 5 or more rows. The problem is, there is a notable difference in loading time with other pages. Is there a technique to estimate the number of rows instead of exactly couting them? So that it saves loading time. For example, when you search with google, you get an estimate of the number of results, how do they do this? Maybe this is not a question for the PHP Mailing list, but if not where is a better place to ask this? Sadly you didn't say which database you are using... so I'll give you an answer for MySQL... I don't know what other DBs do. Say you have: SELECT * FROM table WHERE condition; You only show the n results but these may be paged or offset. What I would do here is: SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE condition LIMIT n OFFSET y; This limits how many results MySQL actually gives you *but* allows you to know what the full number of results would have been if you hadn't used LIMIT via a second statement: SELECT FOUND_ROWS() Hopefully that solves your issue, but perhaps I've missed what you are actually trying to do. Col Is that the kind of answer you are looking for? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Saving loading time at counting rows
Joep Roebroek wrote: I had this question, which I didn't really know where to ask, so I thought to begin at this mailing list. Very basicly said, I count the rows of a table which had approx 5 or more rows. The problem is, there is a notable difference in loading time with other pages. Is there a technique to estimate the number of rows instead of exactly couting them? So that it saves loading time. How about: SELECT COUNT(*) FROM table WHERE criteria ? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] case and accent - insensitive regular expression?
On Sat, Jul 12, 2008 at 10:29 AM, tedd [EMAIL PROTECTED] wrote: At 9:36 AM +0200 7/12/08, Giulio Mastrosanti wrote: Hi, I have a php page that asks user for a key ( or a list of keys ) and then shows a list of items matching the query. every item in the list shows its data, and the list of keys it has ( a list of comma-separated words ) I would like to higlight, in the list of keys shown for every item, the words matching the query, this can be easily achieved with a search and replace, for every search word, i search it in the key list and replace it adding a style tag to higlight it such as for example to have it in red color: if ( @stripos($keylist,$keysearch!== false ) { $keylist = str_ireplace($keysearch,'span style=color: #FF'.$keysearch.'/span',$keylist); } but i have some problem with accented characters: i have mysql with character encoding utf8, and all the php pages are declared as utf8 mysql in configured to perform queries in a case and accent insensitive way. this mean that if you search for the word 'cafe', you have returned rows that contains in the keyword list 'cafe', but also 'café' with the accent. ( I think it has to do with 'collation' settings, but I'm not investigating at the moment because it is OK for me the way it works ). now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa. hope the problem is clear and well-explained in english, thank you for any tip, Giulio Giulio: Three things: 1. Your English is fine. 2. Try using mb_ereg_replace() http://www.php.net/mb_ereg_replace Place the accents you want to change in that and change them to whatever you want. 3. Change: span style=color: #FF'.$keysearch.'/span' to span class=keysearch'.$keysearch.'/span' and add .keysearch { color: #FF; } to your css. Cheers, tedd I may be mistaken (and if I am, then just ignore this as ignorant rambling), but I don't think he's wanting to replace the accented characters in the original string. I think he's just wanting the pattern to find all variations of the same string and highlight them without changing them. For example, his last paragraph would look like this: [quote] now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'span class=keysearchcafe/span' in a string also if it is 'span class=keysearchcafé/span', or 'span class=keysearchCAFÉ/span', or 'span class=keysearchCAFE/span', and vice-versa. [/quote] The best I can think of right now is something like this: ?php function highlight_search_terms($word, $string) { $search = preg_quote($word); $search = str_replace('a', '[aàáâãäå]', $search); $search = str_replace('e', '[eèéêë]', $search); /* repeat for each possible accented character */ return preg_replace('/\b' . $search . '\b/i', 'span class=keysearch$0/span', $string); } $string = now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa.; echo highlight_search_terms('cafe', $string); ? Andrew
Re: [PHP] case and accent - insensitive regular expression?
At 8:31 AM -0400 7/13/08, Andrew Ballard wrote: On Sat, Jul 12, 2008 at 10:29 AM, tedd [EMAIL PROTECTED] wrote: At 9:36 AM +0200 7/12/08, Giulio Mastrosanti wrote: Hi, I have a php page that asks user for a key ( or a list of keys ) and then shows a list of items matching the query. every item in the list shows its data, and the list of keys it has ( a list of comma-separated words ) I would like to higlight, in the list of keys shown for every item, the words matching the query, this can be easily achieved with a search and replace, for every search word, i search it in the key list and replace it adding a style tag to higlight it such as for example to have it in red color: if ( @stripos($keylist,$keysearch!== false ) { $keylist = str_ireplace($keysearch,'span style=color: #FF'.$keysearch.'/span',$keylist); } but i have some problem with accented characters: i have mysql with character encoding utf8, and all the php pages are declared as utf8 mysql in configured to perform queries in a case and accent insensitive way. this mean that if you search for the word 'cafe', you have returned rows that contains in the keyword list 'cafe', but also 'café' with the accent. ( I think it has to do with 'collation' settings, but I'm not investigating at the moment because it is OK for me the way it works ). now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa. hope the problem is clear and well-explained in english, thank you for any tip, Giulio Giulio: Three things: 1. Your English is fine. 2. Try using mb_ereg_replace() http://www.php.net/mb_ereg_replace Place the accents you want to change in that and change them to whatever you want. 3. Change: span style=color: #FF'.$keysearch.'/span' to span class=keysearch'.$keysearch.'/span' and add .keysearch { color: #FF; } to your css. Cheers, tedd I may be mistaken (and if I am, then just ignore this as ignorant rambling), but I don't think he's wanting to replace the accented characters in the original string. I think he's just wanting the pattern to find all variations of the same string and highlight them without changing them. For example, his last paragraph would look like this: [quote] now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'span class=keysearchcafe/span' in a string also if it is 'span class=keysearchcafé/span', or 'span class=keysearchCAFÉ/span', or 'span class=keysearchCAFE/span', and vice-versa. [/quote] The best I can think of right now is something like this: ?php function highlight_search_terms($word, $string) { $search = preg_quote($word); $search = str_replace('a', '[aàáâãäå]', $search); $search = str_replace('e', '[eèéêë]', $search); /* repeat for each possible accented character */ return preg_replace('/\b' . $search . '\b/i', 'span class=keysearch$0/span', $string); } $string = now my problem is to find a way ( I imagine with some kind of regular expression ) to achieve in php a search and replace accent-insensitive, so that i can find the word 'cafe' in a string also if it is 'café', or 'CAFÉ', or 'CAFE', and vice-versa.; echo highlight_search_terms('cafe', $string); ? Andrew Andrew: You may be right -- it's ambiguous now that I review it again. He does say search and replace but I'm not sure if that's what he really wants. It looks more like search with one string and highlight all like-strings. Cheers, 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
Re: [PHP] Most popular per month
Thanks Brady, Wolf, Bernhard! Will write back if i hit a wall but I think your explanations and links should take me all the way. Cheers! Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Shared Authentication Scheme - the reason for the Redirect and POST mailing
Alex Chamberlain wrote: The server and client will initially be programmed in PHP, so I wanted to gather some opinion on whether people wanted another SAS, and what would make them use it over any other?? The company will be there, not only to serve the end user, but to serve the developer as well. If anybody wants to be one of the first users/developers, feel free to contact me on this email address and I will keep you posted. Personally I don't really like the idea of yet another SAS/SSO... The whole point of an SSO is summed up in the first letter of the Acronym... *Single*. If there are multiple different services and different sites implement different SSO systems then there is no longer a *Single* service. Personally, I think that a distributed system with a single *specification* that allows different implementations to exist is the only way forward here and for that, OpenID seems like the best spec out there right now. Perhaps you can explain what your system would offer that would make it better than an OpenID service? Perhaps your service will be OpenID compatible to ensure wider exposure? Perhaps it does more than OpenID? If so what? Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Shared Authentication Scheme - the reason for the Redirect and POST mailing
Alex Chamberlain wrote: The server and client will initially be programmed in PHP, so I wanted to gather some opinion on whether people wanted another SAS, and what would make them use it over any other?? The company will be there, not only to serve the end user, but to serve the developer as well. If anybody wants to be one of the first users/developers, feel free to contact me on this email address and I will keep you posted. Personally I don't really like the idea of yet another SAS/SSO... The whole point of an SSO is summed up in the first letter of the Acronym... *Single*. If there are multiple different services and different sites implement different SSO systems then there is no longer a *Single* service. Personally, I think that a distributed system with a single *specification* that allows different implementations to exist is the only way forward here and for that, OpenID seems like the best spec out there right now. Perhaps you can explain what your system would offer that would make it better than an OpenID service? Perhaps your service will be OpenID compatible to ensure wider exposure? Perhaps it does more than OpenID? If so what? Col I was anticipating this question, but did not want to prompt it. In fact, I started a few weeks ago looking at the OpenID specification, and a PHP server implementation: I found it to be confusing and quite buggy. I hope to implement a OpenID 'frontend' in the future, but not straight away. I also consulted several friends, as well as some of my 18-year-old brothers friends - although a few were very comfortable with the internet and did understand, a lot were confused by the concept of a URL itself - they sort of understood when I explained it was a web address, but could not understand how to use this as a username: this is a fundamental problem of their discovery procedure, in my opinion. Also, a single server system will be more consistent and more secure, and I hope the sharing of personal information *legally* will be a key attraction for most websites. I am at a very early stage, and welcome any comments. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1549 - Release Date: 12/07/2008 16:31 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Saving loading time at counting rows
On Sat, Jul 12, 2008 at 8:26 PM, Joep Roebroek [EMAIL PROTECTED] wrote: I had this question, which I didn't really know where to ask, so I thought to begin at this mailing list. Very basicly said, I count the rows of a table which had approx 5 or more rows. The problem is, there is a notable difference in loading time with other pages. Is there a technique to estimate the number of rows instead of exactly couting them? So that it saves loading time. For example, when you search with google, you get an estimate of the number of results, how do they do this? Maybe this is not a question for the PHP Mailing list, but if not where is a better place to ask this? regards, Joep -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In general get in the mindset of making your web app have fast reads and allow slower writes. So instead of generating a very expensive count query on each request (or read), make sure that you have some pre-generated count elsewhere. You can even tie this generate count routine to any add/edit/delete's to make sure that it is up to date or just cron it for some interval. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://ca3.php.net/manual/en/pdostatement.rowcount.php -- Bastien Cat, the other other white meat
Re: [PHP] scalable web gallery
oic.. the concept is relatively simple.. thanks for the explaination daniel.. On 7/13/08, Daniel Brown [EMAIL PROTECTED] wrote: On Sat, Jul 12, 2008 at 2:37 PM, tedd [EMAIL PROTECTED] wrote: Hey, let's knock off that old shit, newlywed ! Just because you finally got laid doesn't mean you can beat me in memory loss. :-) That's lei'd, sir. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- 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] PDO Question. Number of rows returned
Bastien Koert wrote: On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. http://ca3.php.net/manual/en/pdostatement.rowcount.php This is only good for updates, inserts and deletes.br I am just doing a select. Stephenbr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
On Sun, Jul 13, 2008 at 11:12 AM, Stephen [EMAIL PROTECTED] wrote: Bastien Koert wrote: On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen http://ca3.php.net/manual/en/pdostatement.rowcount.php This is only good for updates, inserts and deletes. I am just doing a select. Stephen my bad. Note you can change the default return array behaviour by change the FETCH_STYLE, default is both ordinal and col name -- Bastien Cat, the other other white meat
[PHP] Re: Saving loading time at counting rows
I think, I will store the count and update it every 24 hours like tedd, says. I have thought of that earlier but was woundering if there might be another method. But I am wondering how google estimates the number of results, but I think that is a more complex thing :P. Thanks for the responses :) regards, Joep 2008/7/13 Joep Roebroek [EMAIL PROTECTED]: I had this question, which I didn't really know where to ask, so I thought to begin at this mailing list. Very basicly said, I count the rows of a table which had approx 5 or more rows. The problem is, there is a notable difference in loading time with other pages. Is there a technique to estimate the number of rows instead of exactly couting them? So that it saves loading time. For example, when you search with google, you get an estimate of the number of results, how do they do this? Maybe this is not a question for the PHP Mailing list, but if not where is a better place to ask this? regards, Joep -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] string comparison
hi i am writing a small application where a user enters a phrase in the textfield and i would like to display all the files present in the root directory which consists of the keyword or keywords entered by the user. i have used a few comparison functions but i am not getting the expected result. $my_file = file_get_contents(filename.html); what ever the user enters whether it is a single word or few words i would like to compare with $my_file in a case insensitive manner. can anyone suggest the best method and how to go about. thanks.
Re: [PHP] IPv6 validation
On Sun, 2008-07-13 at 17:48 +1000, Kevin Waterson wrote: This one time, at band camp, Per Jessen [EMAIL PROTECTED] wrote: No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. 4 years its been, thats incompetence. Something smells like a troll around here *looks suspiciously at Kevin*. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string comparison
On Sun, 2008-07-13 at 21:47 +0530, Sudhakar wrote: hi i am writing a small application where a user enters a phrase in the textfield and i would like to display all the files present in the root directory which consists of the keyword or keywords entered by the user. i have used a few comparison functions but i am not getting the expected result. $my_file = file_get_contents(filename.html); what ever the user enters whether it is a single word or few words i would like to compare with $my_file in a case insensitive manner. can anyone suggest the best method and how to go about. I don't suggest using file_get_contents. It would probably be more efficient (at least less memory intensive) to use fopen() and fread(). Just be sure you overlap each read by $the_size_of_the_largest phrase_or_keyword - 1. Then use stripos() for matching... of course that won't work so well if whitespace doesn't need to match exactly in phrases. In which case you'll need to resort to other techniques. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string comparison
On Jul 13, 2008, at 9:17 AM, Sudhakar wrote: hi i am writing a small application where a user enters a phrase in the textfield and i would like to display all the files present in the root directory which consists of the keyword or keywords entered by the user. i have used a few comparison functions but i am not getting the expected result. I use this script to list archive files from a directory based on keyword. I'd guess a modified version using the keywords from users might work: // create archives box if ($handle = opendir('../diaryarchives/')) { while (false !== ($file = readdir($handle))) { $pos = strpos($file, diary_); $pagemarked = diary._; if ($pos !== false) { //print $filebr; $file_name = ereg_replace ($pagemarked,,$file); $file_name = ereg_replace (.php,,$file_name); //print * $file_namebr; //print $filebr; $archive_list_gather[] = 'lia href=/diaryarchives/'. $file.''.$file_name.'/a/li'; } } closedir($handle); } rsort($archive_list_gather); foreach($archive_list_gather as $value) { $archive_list .= $value; } // build archives box $archives_box = 'div id=diary-archives h3 class=sideimg src=/images/h3s_diaryarchives.gif alt=Diary Archives width=225 height=20 //h3 ul '.$archive_list.' /ul /div'; // publish archives box $filename = PATHA.'/diaryarchivesbox.php'; publishpages($archives_box, $filename); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IPv6 validation
Kevin Waterson wrote: This one time, at band camp, Per Jessen [EMAIL PROTECTED] wrote: No, it's a simple matter of need. People also run apache 1.x, mysql 3.x etc. There are still Linux 2.2 and 2.4 systems out there too. 4 years its been, thats incompetence. Kevin Kevin, I don't know how old you are nor how long you have been in IT, but your opinions suggest you might be fairly inexperienced. Like I said, remaining back-level with software or an OS it's a matter of need or choice. Sometime both are heavily influenced by time and money. Not upgrading something to PHP5 due to lack of manpower is not incompetent at all, it's reality. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Freelance PHP development in India
Dear friends. I am looking for freelance web developers in India. Can contact me? Thanks Denis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Freelance PHP development in India
Denis L. Menezes wrote: Dear friends. I am looking for freelance web developers in India. Can contact me? Thanks Denis Why just in India? There are a number of us available via the world. Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need advice on a free DB hosting site
hi hello everyone im stil new here i just want some advice...now im working on a database install script in phpjust a simple one... i just need to test it online thats why i need advice on a database hosting site that is free.. that also i can activate it with a username and password, can create database or just select it.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php