From marcin.szkudlarek at gmail.com Wed Nov 1 06:27:21 2006 From: marcin.szkudlarek at gmail.com (Marcin Szkudlarek) Date: Wed, 1 Nov 2006 11:27:21 +0000 Subject: [nycphp-talk] cake url question Message-ID: I would like to map multiple url to one controller method like this: example.com/bmw example.com/toyota example.com/nissan .. should invoke method (for example "view") in my controller with parameter "bmw", "toyota" etc. Probably I should configure it in routes.php but I don't have idea how. Regards, Marcin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ramons at gmx.net Wed Nov 1 07:14:05 2006 From: ramons at gmx.net (David Krings) Date: Wed, 01 Nov 2006 07:14:05 -0500 Subject: [nycphp-talk] rtrim broken? In-Reply-To: <564E745B-E474-4F84-A7DB-68F56F1ED425@sala.ca> References: <4547F957.4030006@gmx.net> <564E745B-E474-4F84-A7DB-68F56F1ED425@sala.ca> Message-ID: <45488F8D.40004@gmx.net> Hi, yes, $text is the string passed to rtrim, which in retrun is supposed to overwrite what is in $text previously. Kinda like $k = $k++; When k was 5 before this line it will be 6 after. That string in question is build by a loop, so I may take your advise and do it differently. That still doesn't explain why rtrim doesn't work as I expect it to. David K. Dell Sala wrote: > Are you reassigning the result to $text? The first argument is not > passed by reference -- instead, it returns the trimmed string. > > $text = rtrim($text, ', '); > echo $text; > > BTW: if this string is build by a loop, there is another idiom that I > find cleaner than stripping off the last separator: Build text as an > array, then implode it. > > $text = array(); > foreach (range(0, 2) as $i) { > $text[] = 'blah'; > } > $text = implode(', ', $text); > > > -- Dell > > > On Oct 31, 2006, at 8:33 PM, David Krings wrote: > > >> Hi, >> >> I have a string that looks like this >> $text = 'blah, blah, blah, '; >> I want to use rtrim to cut off the last comma and the whitespace. >> So I use >> rtrim($text, ', '); >> >> To my surprise, it doesn't cut anything off. When I echo $text the >> comma >> and the space are still there. >> >> Is rtrim broken or my logic or my script? >> >> David K. >> >> _______________________________________________ >> New York PHP Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> NYPHPCon 2006 Presentations Online >> http://www.nyphpcon.com >> >> Show Your Participation in New York PHP >> http://www.nyphp.org/show_participation.php >> > > _______________________________________________ > New York PHP Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > NYPHPCon 2006 Presentations Online > http://www.nyphpcon.com > > Show Your Participation in New York PHP > http://www.nyphp.org/show_participation.php > > > From ramons at gmx.net Wed Nov 1 07:23:12 2006 From: ramons at gmx.net (David Krings) Date: Wed, 01 Nov 2006 07:23:12 -0500 Subject: [nycphp-talk] rtrim broken? In-Reply-To: <45488F8D.40004@gmx.net> References: <4547F957.4030006@gmx.net> <564E745B-E474-4F84-A7DB-68F56F1ED425@sala.ca> <45488F8D.40004@gmx.net> Message-ID: <454891B0.2040308@gmx.net> Hi, just after I hit send it made 'ping' in my mind and I did see what you meant. My script is wrong. rtrim($text, ', '); does trim the string alright, I just tell it to send the result to nowhere as I don't pick up the trimmed string. DUH! I changed it to $text = rtrim($text, ' ,'); and now that works. The problem was between keyboard and chair as so often. David K. David Krings wrote: > Hi, > > yes, $text is the string passed to rtrim, which in retrun is > supposed to overwrite what is in $text previously. Kinda like > $k = $k++; > When k was 5 before this line it will be 6 after. > > That string in question is build by a loop, so I may take your advise > and do it differently. That still doesn't explain why rtrim doesn't work > as I expect it to. > > David K. > > Dell Sala wrote: > >> Are you reassigning the result to $text? The first argument is not >> passed by reference -- instead, it returns the trimmed string. >> >> $text = rtrim($text, ', '); >> echo $text; >> >> BTW: if this string is build by a loop, there is another idiom that I >> find cleaner than stripping off the last separator: Build text as an >> array, then implode it. >> >> $text = array(); >> foreach (range(0, 2) as $i) { >> $text[] = 'blah'; >> } >> $text = implode(', ', $text); >> >> >> -- Dell >> >> >> On Oct 31, 2006, at 8:33 PM, David Krings wrote: >> >> >> >>> Hi, >>> >>> I have a string that looks like this >>> $text = 'blah, blah, blah, '; >>> I want to use rtrim to cut off the last comma and the whitespace. >>> So I use >>> rtrim($text, ', '); >>> >>> To my surprise, it doesn't cut anything off. When I echo $text the >>> comma >>> and the space are still there. >>> >>> Is rtrim broken or my logic or my script? >>> >>> David K. >>> >>> From cliff at pinestream.com Wed Nov 1 08:13:32 2006 From: cliff at pinestream.com (Cliff Hirsch) Date: Wed, 1 Nov 2006 08:13:32 -0500 Subject: [nycphp-talk] rtrim broken? In-Reply-To: <454891B0.2040308@gmx.net> Message-ID: <001c01c6fdb7$87ba64e0$12a8a8c0@HirschLaptop> >> DUH! The problem was between keyboard and chair as so often. I find my best breakthroughs and epiphanies are solved while driving, playing tennis (incredibly distracting and detrimental to the tennis game), and performing other mindless activities away from the keyboard. From jonbaer at jonbaer.com Wed Nov 1 10:12:12 2006 From: jonbaer at jonbaer.com (Jon Baer) Date: Wed, 1 Nov 2006 10:12:12 -0500 Subject: [nycphp-talk] cake url question In-Reply-To: References: Message-ID: <4A52B26D-8C51-4F92-A2D9-A63817C13FB7@jonbaer.com> You should place them in a central controller or else you will get bit later ... Ie: example.com/cars/bmw example.com/cars/toyota example.com/cars/nissan In your routes.php: $Route->connect('/cars/*', array('controller' => 'Car', 'action' => 'view')); In your car controller: function view($car = '') { if ($car) { $cars = $this->Car->findAllByCar($car); // (dynamic) available in 1.2 } else { $cars = $this->Car->findAll(); } $this->set('cars',$cars); $this->render('view'); } If you *need* to have those URLs instead you can just move the Route up one level. - Jon On Nov 1, 2006, at 6:27 AM, Marcin Szkudlarek wrote: > I would like to map multiple url to one controller method like this: > > example.com/bmw > example.com/toyota > example.com/nissan > .. > should invoke method (for example "view") in my controller with > parameter "bmw", "toyota" etc. > Probably I should configure it in routes.php but I don't have idea > how. > > Regards, > > Marcin > _______________________________________________ > New York PHP Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > NYPHPCon 2006 Presentations Online > http://www.nyphpcon.com > > Show Your Participation in New York PHP > http://www.nyphp.org/show_participation.php -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashaw at polymerdb.org Wed Nov 1 10:53:10 2006 From: ashaw at polymerdb.org (Allen Shaw) Date: Wed, 01 Nov 2006 09:53:10 -0600 Subject: [nycphp-talk] rtrim broken? In-Reply-To: <564E745B-E474-4F84-A7DB-68F56F1ED425@sala.ca> References: <4547F957.4030006@gmx.net> <564E745B-E474-4F84-A7DB-68F56F1ED425@sala.ca> Message-ID: <4548C2E6.5070503@polymerdb.org> Dell Sala wrote: > BTW: if this string is build by a loop, there is another idiom that I > find cleaner than stripping off the last separator: Build text as an > array, then implode it. Some informal benchmarking on my own showed that creating and imploding the array generally takes longer than appending and stripping, depending on the number of iterations in the loop: for fewer iterations, use append-and-strip; for more iterations, use and array and implode. -- Allen Shaw Polymer (http://polymerdb.org) From nate at cakephp.org Wed Nov 1 11:21:28 2006 From: nate at cakephp.org (Nate Abele) Date: Wed, 1 Nov 2006 11:21:28 -0500 Subject: [nycphp-talk] cake url question In-Reply-To: References: Message-ID: <9A3FF129-5D43-439C-9FDD-5656B9EC5145@cakephp.org> Hi Marcin, Cake 1.2 adds support for this. In app/config/routes.php, you can add a route like the following: Router::connect('/:car_brand', array('controller' => 'cars', 'action' => 'view'), array('car_brand' => 'bmw|toyota|nissan')); The only issue is that all the possible values of car_brand must be hard-coded into the route. -Nate > Date: Wed, 1 Nov 2006 11:27:21 +0000 > From: "Marcin Szkudlarek" > Subject: [nycphp-talk] cake url question > To: talk at lists.nyphp.org > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > I would like to map multiple url to one controller method like this: > > example.com/bmw > example.com/toyota > example.com/nissan > .. > should invoke method (for example "view") in my controller with > parameter > "bmw", "toyota" etc. > Probably I should configure it in routes.php but I don't have idea > how. > > Regards, > > Marcin > -------------- next part -------------- From r.mariotti at fdcx.net Wed Nov 1 11:38:54 2006 From: r.mariotti at fdcx.net (R. Mariotti) Date: Wed, 01 Nov 2006 11:38:54 -0500 Subject: [nycphp-talk] OT: any printing to NTA thin clients? Message-ID: <4548CD9E.9020205@fdcx.net> Sorry for the OT post. But most subscribers work in the industry and some MIGHT have some knowledge of sources of information. I've just inherited the support and further app development for a bunch of thin clients running web based apps on NTA 6010 thin clients. These seem to run some flavor of *nix as their proprietary OS. My questions relate to printing to these boxes: It appears that they may use cups as their print server software (as I can access it local with localhost:631 and actually get connected. But, trying to do anything requires the admin username and password. As no one has ever (so they say) set this up and I do not have any real admin access (because its a closed OS) what can one use for these values? If anyone is familiar with this line -OR- if anyone knows of any source of info (other than their source - devonit.com) please advise. And, of course, if anyone has any actual usable knowledge of these devices please share it? Thanks for reading and thanks for responding. BM From paul at devonianfarm.com Wed Nov 1 11:55:44 2006 From: paul at devonianfarm.com (Paul Houle) Date: Wed, 01 Nov 2006 11:55:44 -0500 Subject: [nycphp-talk] PHP patterns and antipatterns (was "rtrim broken?") In-Reply-To: <4547F957.4030006@gmx.net> References: <4547F957.4030006@gmx.net> Message-ID: <4548D190.7070005@devonianfarm.com> David Krings wrote: > Hi, > > I have a string that looks like this > $text = 'blah, blah, blah, '; > I want to use rtrim to cut off the last comma and the whitespace. So I use > rtrim($text, ', '); > Creating delimited lists in strings is a common task, and there are a number of patterns for doing it. It's a task that PHP programmers in particular seem to struggle with. I don't like the pattern "create an invalid list, then fix it up afterwards" and the related pattern "create an invalid list and expect the user of the list to deal with it". All too often the "fix it up afterwards" gets forgotten or broken, or the "user of the list" doesn't deal with the invalid list correctly. Until recently, I used the following pattern $list=""; foreach($values as $v) { $item=process($v); if ($list) { $list .= ","; } $list .=$item; } Some will complain that I'm writing too many LoC. More seriously, it's easy to code a pattern like this wrong. One day I did this, and decided to create a function to (i) reduce errors, and (ii) reduce LoC. function append_to_list(&$list,$item,$delimiter=",") { if($list) { $list .= ","; } $list .= $item; } Now I write $list=""; foreach($value as $v) { $item=process($v); append_to_list($list,$item); } In terms of LoC, this is as good as any of the other solutions, but has the advantage that the list is always in a valid state. (For instance, you can do a "return" to drop out of the loop at any time, the list is valid if an exception gets thrown,...) I added "append_to_list" to a file that contains utility functions that address my other PHP Pet Peeves... You know... $whatever=""; if (isset($_POST["whatever"])) { $whatever=$_POST["whatever"]; } you might find this pattern coded up 100 different ways, from the cute $whatever=isset($_POST["whatever"]) ? $_POST["whatever"] : ""; to monstrosities that end up indenting hundreds of lines of code ten tabs because the programmer stacked a bunch of if(isset())'s. Now I write $whatever=array_get($_POST,"whatever"); this returns the empty string if $_POST["whatever"] is not set... An optional third parameter lets you pick a different default value if you don't like "". Another thing that drives me up the wall is You ought to write but that's painful. It's nice to have function q($string) { print htmlspecialchars($whatever); } So designers can write beautiful, simple and correct code: User name: Alas, there are two problems with this approach: (1) It's tough to get other programmers on the team to be aware of this kind of library. They end up scratching their heads when they see functions like this. Getting them to take the initiative to actual use them is even harder. (2) Defining functions in the global namespace pollutes the global namespace. If you're pulling in libraries from multiple sources, there's a lot of risk that other people are going to claim names like "q()" and "array_get()". It's not fun anymore if you have to write PAULS_PET_PEEVES::q($user_name); In some cases, however, you can do something like $p=new PAULS_PET_PEEVES(); $p->q(...); which at least leaves the option of changing $p to something else in places where you really need to. This is particularly good for greenfield projects: for instance, I've got a struts-like "action-view-controller" framework where it's easy to pass a few utility objects with single-character names into the views that define anti-antipattern functions... Views never end up with code like because you can just write From jbaer at VillageVoice.com Wed Nov 1 11:54:49 2006 From: jbaer at VillageVoice.com (Baer, Jon) Date: Wed, 1 Nov 2006 11:54:49 -0500 Subject: [nycphp-talk] cake url question In-Reply-To: <9A3FF129-5D43-439C-9FDD-5656B9EC5145@cakephp.org> Message-ID: <4D2FAD9B00577645932AD7ED5FECA24503A17C19@mail> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nate - Is there an updated timeframe to when v1.2 will launch? - - Jon - -----Original Message----- From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On Behalf Of Nate Abele Sent: Wednesday, November 01, 2006 11:21 AM To: talk at lists.nyphp.org Subject: Re: [nycphp-talk] cake url question Hi Marcin, Cake 1.2 adds support for this. In app/config/routes.php, you can add a route like the following: Router::connect('/:car_brand', array('controller' => 'cars', 'action' => 'view'), array('car_brand' => 'bmw|toyota|nissan')); The only issue is that all the possible values of car_brand must be hard-coded into the route. - -Nate > Date: Wed, 1 Nov 2006 11:27:21 +0000 > From: "Marcin Szkudlarek" > Subject: [nycphp-talk] cake url question > To: talk at lists.nyphp.org > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > I would like to map multiple url to one controller method like this: > > example.com/bmw > example.com/toyota > example.com/nissan > .. > should invoke method (for example "view") in my controller with > parameter "bmw", "toyota" etc. > Probably I should configure it in routes.php but I don't have idea > how. > > Regards, > > Marcin > -------------- next part -------------- _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (MingW32) iD8DBQFFSNFZ99e5DI8C/rsRAoGOAJ4t9EBN00yPEEt8pk1xq6X5I6FqgwCcDNqy apSZOvOgdirRNbNUU+/jLdY= =Nwok -----END PGP SIGNATURE----- From lists at danhorning.com Wed Nov 1 12:58:56 2006 From: lists at danhorning.com (Dan Horning) Date: Wed, 01 Nov 2006 12:58:56 -0500 Subject: [nycphp-talk] paging Peter Sawczynec In-Reply-To: References: Message-ID: <4548E060.1090400@danhorning.com> if you're around I'm looking to work with you on a project. -- Dan Horning - danhorning.com American Digital Services - americandigitalservices.com Where you are only limited by imagination. 1-866-493-4218 (direct) / 1-800-863-3854 (main number) From tuon1 at netzero.net Wed Nov 1 14:20:50 2006 From: tuon1 at netzero.net (tuon1 at netzero.net) Date: Wed, 1 Nov 2006 19:20:50 GMT Subject: [nycphp-talk] Mysql question! Message-ID: <20061101.112122.10554.1161019@webmail18.nyc.untd.com> An embedded and charset-unspecified text was scrubbed... Name: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsnyder at gmail.com Wed Nov 1 20:36:54 2006 From: chsnyder at gmail.com (csnyder) Date: Wed, 1 Nov 2006 20:36:54 -0500 Subject: [nycphp-talk] mysql_real_escape_string WAS: Mysql question! In-Reply-To: <4547E89B.20104@gmx.net> References: <002c01c6fd3e$2a01ab70$12a8a8c0@HirschLaptop> <4547E89B.20104@gmx.net> Message-ID: On 10/31/06, David Krings wrote: > I can't think of any way on how to get \x1a as user input Simple. Write a php script that connects to your server and sends \x1a as input. :-) Don't forget, it's not just humans behind web browsers that we have to worry about. From jonbaer at jonbaer.com Wed Nov 1 21:55:27 2006 From: jonbaer at jonbaer.com (Jon Baer) Date: Wed, 1 Nov 2006 21:55:27 -0500 Subject: [nycphp-talk] GData / PHP5 (4?) Message-ID: It looks like the full GData object model was ported to PHP (or has been for a while now?) ... http://google-code-updates.blogspot.com/2006/10/google-data-apis-now- with-php.html Any feedback? And is there a PHP4 library anywhere? - Jon From ariel.kulkin at gmail.com Wed Nov 1 22:56:50 2006 From: ariel.kulkin at gmail.com (Ariel Kulkin) Date: Wed, 1 Nov 2006 22:56:50 -0500 Subject: [nycphp-talk] Passing parameters with the click of a button. In-Reply-To: <556034ce0611011954n52ac2c25n8aa17ccf745f3e37@mail.gmail.com> References: <556034ce0610302025j10592888g2d2b1b41a61ef5bf@mail.gmail.com> <556034ce0611011954n52ac2c25n8aa17ccf745f3e37@mail.gmail.com> Message-ID: <556034ce0611011956o545b1ef8x11b9db7d35f3f347@mail.gmail.com> All, I appreciate your responses, but for some reason Brian's suggestion (which is the one I can most comfortably follow, given my knowledge) is not working. Brian suggested: But once I put any parameter after Referral.php, all I get is that the "The Page cannot be found". I even tried replacing the button for an image and also a text link... and I can't seem to be able to use either, to open the window AND pass the user_id parameter (which is, indeed, a php variable). An example of the failed attempt using a text link: Just FYI : rstuserdata is my recordset, us_user_id is the field that contains (for sure) the value which user_id should take user_id is the parameter I want to pass.. USE THIS TEXT AS LINK Any thoughts? I know that, collectively, you've suggested other alternatives... but given my limited skill, this one has a syntax I understand, and I know where to put it, in the code... Your advise will be greatly appreciated. Thanks! Ariel. On 10/31/06, Brian Dailey wrote: > > ---------- Forwarded message ---------- > From: "Brian Dailey" < kungfoofool at gmail.com> > To: "NYPHP Talk" > Date: Tue, 31 Oct 2006 06:08:13 -0500 > Subject: Re: [nycphp-talk] Passing parameters with the click of a button. > Ariel, > > Assuming user_id is a PHP variable, you should be able to do it like this. > > onclick="MM_openBrWindow('/Pop%20Ups/Referrals.php?user_id=','Referrals','scrollbars=yes,resizable=yes,width=500,height=600')"/> > > Yes
> > And in referrals.php... > > $user_id = $_GET['user_id']; > ?> > > That's *one* way to do it. However, it's very insecure. If you're > setting variables like user_id they should never be accessible from a > GET param where the user can manipulate it directly. It would be best > to set user_id in a SESSION variable somewhere - then you can access > it from any page you want without having to worry about constantly > passing it as a parameter. > > On 10/30/06, Ariel Kulkin < ariel.kulkin at gmail.com> wrote: > > Problem Statement: With the click of a button, I need to open a new > window > > (to capture "user referrals"), and pass to it a parameter that will be > used > > to track the user id of the individual who originated those referrals. > > > > I have no problems opening the window with the button click: > > I can't quite get the syntax, however, to pass the user_id parameter... > > How do I go about passing the user_id parameter to the newly open > window? > > > > CODE: > > > > Do you know anybody who may benefit from using XYZ System? > > > >