[PHP] Function size
Hi gang: On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: > A rule of thumb is no more than 50 lines per > function, most much less. Back in the day when we didn't have nifty > gui screens and an 24 line terminals (yay green on black!), if a > function exceeded one printed page, it was deemed too long and marked > for refactoring. You hit upon a theory of mine -- and that is our functions grow in size up to our ability to view them in their totality. When our functions get beyond that limit, we tend to refactor and reduce. I know from the last several decades of programming, my functions have increased in number of lines. But, they have reached a limit that limit is generally about the number of lines I can read in half of my monitor's height. This of course, is dependent on monitor resolution, font-size, and how far I am sitting from the monitor. But I think this is a natural and physical limit that we don't normally recognize. I can cite studies that support my theory. It would be an interesting survey to ask programmers to review their code and provide the average number of lines in their functions AND how many lines of code their monitor's can display. In other words, look at your editor; count the number of lines your monitor can display; estimate the number of lines in your average function; and report the findings. For example, mine is about half -- my monitor can display 55 lines of code and my average function is around 25 lines. YMMV. Interesting, yes? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 23, 2012, at 11:49 AM, shiplu wrote: > On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: > When number of lines becomes the criteria of function size? Wouldn't it > depends on the task the function is doing? You missed the point. Of course, the difficulty of the task of a specific function will directly contribute to the number of lines of code for that function, but that's not what I was talking about. What I was talking about was that what we can grasp in one view, we can understand better. If the code lies outside of our view, then we understand it less. I can support this claim with numerous articles/books/studies of human visual limits vs short-term memory. I am only bringing this forward for us to consider in our writing code. If we know why we do things, then we can better understand what we do. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 23, 2012, at 12:21 PM, Robert Cummings wrote: > On 12-05-23 12:15 PM, Tedd Sperling wrote: >> What I was talking about was that what we can grasp in one view, we can >> understand better. If the code lies outside of our view, then we understand >> it less. I can support this claim with numerous articles/books/studies of >> human visual limits vs short-term memory. I am only bringing this forward >> for us to consider in our writing code. If we know why we do things, then we >> can better understand what we do. > > That's why I code in 5px font. On my huge monitor I sometimes find the code > is shaped like a tiger, or a dragon, I swear I even saw Piccolo. It really > does help to see the big picture :B > > Cheers, > Rob. Forgive me -- I should have know better. This is a bit like talking to my grandkids -- if it doesn't involve dulling crayons, there's no point. :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 23, 2012, at 3:49 PM, Ashley Sheridan wrote: > > I'm of the same mind. Generally I'll split a function if I'm reusing more > than a couple of lines of code. I only split a "large" function if it's > actually doing several things, if it happens to need 200 lines to perform one > 'step' then I'll leave it as is. While I do prefer my functions to fit into a > single 'screen', it rarely happens quite like that, because I move from > screen to screen with different resolutions, so there's no constant limit for > me. > > As a rough example, on a random selection of 27 functions taken from a > controller on a site I worked on I get these general statistics: > > Functions: 27 > Mean lines: 22.5 > Mode lines: 3 > Max lines: 218 > > The function with 218 lines is a large switch, and it doesn't make sense to > do it any other way, because it would actually end up less readable. I see you and I are like minds in many ways. I had one large switch block that had 255 different cases. Oddly enough I was parsing a "Tiger" data file (USGS survey data) that contained 255 different record types. Each record type required a different function to parse the data and render it's portion of the overall map. That lead to me create a linked-list that held the memory addresses of both data and function. That way simply accessing the linked list coupled data to function and drew the map. It was neat. I find it also neat, while I'm not an expert on the subject, eliminating the need for 'switch' and 'if' statements via extending classes in OO. Shiplu provided a link, which I found interesting: http://www.youtube.com/watch?v=4F72VULWFvc It showed how one can eliminate such conditionals, but at the same time it massively increased the code to preform 1 + 2 * 3. :-) And to others, I don't need comment on how I missed the point -- I didn't. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 24, 2012, at 8:37 AM, Steven Staples wrote: > Tedd, > > I think the length of code depends on a few different factors, what if you > have your docblocks, and comment lines, as well as your bracing style? > Where do you consider your function to start? It starts where it starts. It doesn't make any difference how you do it, it's what you see in one view that counts. If you are very verbose with spaces, brace styles, comments, and such, then your functions have less actual statement lines than others with more cryptic coding styles, but I would bet the line limit of total number of lines remain in place regardless. This is more a condition of physical/mental limits on humans than it is on coding style. So, there's no "better" or "worse' point here -- it is more an observation. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function size
On May 24, 2012, at 4:48 PM, tamouse mailing lists wrote: > Yes, I think that is *exactly* the criterion-- not a mystery or an emergent > thing, really, was a pretty expicit reasoning--being able to see/scan the > entire function on one page (or now in one screenful) makes it much easier to > see what happens in the function, where blocks open/close, and it forces one > to break up code into logical units. While it may be obvious to you, there is considerable study on the ways we perceive things -- this is just one we apparently take for granted ... at least now. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 24, 2012, at 5:01 PM, Ashley Sheridan wrote: > On Thu, 2012-05-24 at 15:48 -0500, tamouse mailing lists wrote: >> On May 23, 2012 9:14 AM, "Tedd Sperling" > > wrote: >> > >> > H >> Yes, I think that is *exactly* the criterion-- not a mystery or an emergent >> thing, really, was a pretty expicit reasoning--being able to see/scan the >> entire function on one page (or now in one screenful) makes it much easier >> to see what happens in the function, where blocks open/close, and it forces >> one to break up code into logical units. >> > > With the odd exception being where code is more readable in a longer format, > as seen with my and several others examples of long functions that rely > heavily on switches. > > -- > Thanks, > Ash Yep, not everything can it -- there are exceptions. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Too many arrays! My head is exploding!
On 29 May 2012 18:15, Gary wrote: > Okay, let's assume I have three "things", A, B, and C. I need to produce > an array with a list of all possible combinations of them, however many > there might be in those combinations: e.g. A, B, C, D, AB, AC, AD, BC, > ABC (not sure if I've missed any!). Normally I'm pretty good at working > this stuff out, but to be honest I'm struggling with this one, at least > to do it in any kind of elegant way. Does anyone have any ideas? Sure, but what you are asking for is a permutation and not a combination. Here's a good read on the subject: http://www.mathsisfun.com/combinatorics/combinations-permutations.html Here's the deciding difference: * If the order doesn't matter, then it's a combination. * If the order does matter, then it's a permutation. A combination of ABC is ABC. However, the permutation of ABC is: ABC ACB BAC BCA CAB CBA Oddly enough, a "combination lock" is a misnomer -- it should be a "permutation lock" because the order of the "combination" does matter. In any event, here's the code for as large a permutation as you may want: http://www.webbytedd.com/b1/permutation/ Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 29, 2012, at 10:20 AM, Stuart Dallas wrote: > -snip- > Besides, truth is subjective, but then so is everything, including that > assertion. > > -Stuart You reply was longer than my monitor was high so I can't give an immediate reply -- I have to scroll. :-) However, with that said, you made good points and I don't disagree with any of them. As for me, I was speaking from my experience where the size of my functions over the last few decades has grown (up to a point) with my increasing monitor size. However, my eyesight has not improved and thus should be figured into this somehow. As I said before, mine is just an observation that supports the limits in reception/comprehension articles I have read. I think your 24 line terminal vs the 30" monitor argument is a valid one, up to a point. But I think the problems (if any) would depend upon many factors -- too numerous to elaborate here. But let me pose an idea. When I was in college, my degrees were in Geology. My Summer Field study (6 weeks) was to map out Geologic outcrops on a USGS topographic map. At the end of the study, all maps that matched the Professors' maps, were given the highest grades (mine the highest in all modesty). Not because they were alike, but because they approached the "truth" of the matter. The truth here was not subjective for there was only ONE defining truth and that could be discovered by detailed mapping. We all (including the Professors) approached the same problem in the same way and reached similar results. The closer to the truth, the more similar the maps. Over the years I've seen programming languages converge producing single solutions for common tasks, such as a FOR loop and IF statements. These seem to be universal constructs in programming logic. So my question is, as in my Geology study "Is this convergence in programming logic discovering the truth of the task?" Do you see what I mean? If so, then maybe the way we break down problems into smaller subsets might also be approaching an optimum method as well. I used to use (30+ years ago): 1) Input; 2) Calculation; 3) Display; as the main categories in my division logic to tackle problems and that was long before I heard of MVC. So, what I am saying is that we might all be approaching and contributing to an overall optimal logical solution in programming. Kind of an ant-colony think sort of thing. The solution is certainly not simple, but it might be an universally single solution to all the problems we perceive. Said only for "Food for thought". Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Too many arrays! My head is exploding!
On May 29, 2012, at 11:41 AM, Adam Richardson wrote: > On Tue, May 29, 2012 at 10:55 AM, Tedd Sperling wrote: >> On 29 May 2012 18:15, Gary wrote: >> >>> Okay, let's assume I have three "things", A, B, and C. I need to produce >>> an array with a list of all possible combinations of them, however many >>> there might be in those combinations: e.g. A, B, C, D, AB, AC, AD, BC, >>> ABC (not sure if I've missed any!). Normally I'm pretty good at working >>> this stuff out, but to be honest I'm struggling with this one, at least >>> to do it in any kind of elegant way. Does anyone have any ideas? >> >> Sure, but what you are asking for is a permutation and not a combination. > > His example seems to suggest order does not matter (I've omitted 'D', > which I suspect was a typo given the set of A, B, and C): Ahhh yes, he said AB, AC, BC, and ABC, but not AB, BA, AC, CA, and so on. I stand corrected. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On May 29, 2012, at 5:06 PM, Paul M Foster wrote: > > I think a lot of coders try to be kewler than the next 18 guys who are > gonna have to look at the code, so they use a lot of "compression" > techniques to reduce LOC. That's not kewl to me. > Plus, they're lazy. I'd rather see everything > with lots of spaces and plenty of comments and blank lines. Especially > since I'm sometimes that 18th guy to look at the code. > > Paul Same here. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [foreach] - is it proper to...
On May 31, 2012, at 12:48 PM, Tristan wrote: > I'm using Zend Studio and it had a suggestion that I do a foreach as such > > foreach($entry as $entry){ > > } > > instead of > > foreach($entries as $entry){ > > } > > they both seem to work but, from a readability standpoint and just makes > more sense to me to use method 2. Is it bad practice to go with the 1st > method of coding or preferred? > > Thanks, T Let's look at that. In the first case you're doing a foreach loop on an array entitled $entry (single) using a variable entitled the same name representing the values in each element of the array -- that doesn't make sense even if it works or is recommended by Zend Studio. That would be a hell of a bug to find. In the second case, I find the syntax more correct. You are doing a foreach loop on an array entitled $entries (plural) using the values contained in the array as $entry (single) -- that makes much more sense to me. My $0.02 Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cyberweaponry
Hi gang: This is a little early for Friday's "Open Comment" day, but my memory is increasingly more short term and by tomorrow I might forget -- so, here goes. I watched a interview today where an security expert claimed that the Flame Virus was written in a scripted language named lua (http://www.lua.org/). He said that this was unusual because typically such viruses are written in languages like Ruby-on-Rails and such. So, my question to the group -- has PHP produced any viruses? If not, could it? If so, can anyone elaborate on the details? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cyberweaponry
On May 31, 2012, at 7:45 PM, Ross McKay wrote: > On Thu, 31 May 2012 13:21:07 -0400, Tedd Sperling wrote: > >> [...] >> I watched a interview today where an security expert claimed that >> the Flame Virus was written in a scripted language named lua >> (http://www.lua.org/). > > That's surprising... I'm intrigued, can you supply a link? No, there was no link. If I remember correctly, it was an interview done on Fox News. >> He said that this was unusual because typically such viruses are >> written in languages like Ruby-on-Rails and such. > > Um, really? I very much doubt that. AFAIK, most true viruses are written > in a compiled language, and many trojans as well. RoR websites would > definitely be a vulnerability target though... Yeah, that's what I thought, but this guy was held out to be one of the foremost experts on cyber-warfare. So, I listened and asked. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] disabled cookies
On Jun 3, 2012, at 5:21 PM, Ashley Sheridan wrote: > > There is a new law been passed in the UK that makes non-essential cookies > opt-in only, so you must get permission in order to use them. What's a non-essential cookie? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] disabled cookies
On Jun 4, 2012, at 6:13 PM, Ashley Sheridan wrote: > > Yeah, it's been such a pain, as nobody over here is quite sure how the > hell it'll be enforced either, or if it even will be. It's also pretty > vague as to just where the line gets drawn. The official government > sites on this are pretty black and white, but don't clearly address the > grey areas. I think this is definitely a case of the persons making the > laws don't understand the technology involved, which sadly seems to be > the case across a lot of tech laws being passed world-wide of late :( > > -- > Thanks, > Ash This is what I put on my site to address the Cookie issue: http://sperling.com/contact.php Do you think it would be enough? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Happy Diamond Jubilee everyone!
On Jun 1, 2012, at 1:44 PM, Ashley Sheridan wrote: > This is a bit of a shameless plug, but it is a Friday and a pretty > special weekend over here. > > I recently got to work on something a bit fun at work in my spare time > and they liked it so much that it got used internally to celebrate the > jubilee weekend. > > This is the result http://jubilee.themlondon.com > > For those of you interested, the leg-work is done by a bunch of PHP > scripts run in the background via cron, split into 3 tasks: > > > 1. A script goes out and searches Twitter for tweets that mention >the jubilee, one instance per keyword and records those to a DB >to limit the draw on the Twitter API > 2. A second script goes over those tweets and pulls in all the >non-default profile images for each unique user > 3. Lastly, the image is built as 12 separate tiles every half hour, >using PHP and GD to match the average colour of each profile pic >to a spot on the image, and then these are stitched together for >the final image > > Anyway, hope you guys all have a great weekend, more so if you're > unlucky enough to be working over the whole 4 days :-/ > > -- > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Just saw it -- far out! Cheers, tedd PS: You Brits have too much free time on your hands. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A Question of SESSION
Hi Daniel and gang: Considering I'm never afraid to show my ignorance, please review the following example. Because of the way I normally use sessions and considering this way works for me, I thought I knew what sessions were about -- but my faith is eroding. Cases in point 1. The following is the way I normally use sessions (with COOKIES turned ON): http://www.webbytedd.com/b/sessions It works. 2. Considering that people may have their COOKIES turned OFF, I tried this: http://www.webbytedd.com/b/sessions1/ It works when COOKIES are turned ON, but the SID does not appear in the URL -- I find that odd. However, if COOKIES are turned OFF, then SID does appear in the URL, but the process of passing session variables doesn't work -- I find that confusing. What's the point of passing the SID if it isn't going to be used? 3. Looking for an explanation, I came across Daniel's post to the PHP manual, which follows: http://www.webbytedd.com/b/sessions3 Now I am totally bonkers. What am I not getting? Cheers, tedd t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If PHP Were British
On Jun 22, 2012, at 5:07 PM, Daevid Vincent wrote: > http://www.addedbytes.com/blog/if-php-were-british/ Oh, that is too funny! I'll counter with my Hill-Billy version: --- echo(); yell('revenewers commin'); --- var_dump(); take_a_dump(); preferred: leave_one(); --- if: what_ya_think($huh) { //codie here } ternary: $gospel = $thisn ? $thatn : $the_othern; --- switch: whats_thisn($quess) { thisn $thunk_one: //codie here that_settles_it: thisn $thunk_tu: //codie here that_settles_it: thisn $thunk_3: //codie here that_settles_it: othern $not_thunk: //codie here that_settles_it: } --- try/catch: what_the { //codie here } what_the_hell(kin $whut) { buy_the_farm('Sh#t'); } --- class: What? Never went to class. :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's happened to our newsgroup?
On Jun 26, 2012, at 3:21 PM, Al wrote: > No postings for days. > Maybe everyone learned it -- no new questions. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Checking
On Jul 9, 2012, at 2:40 PM, Floyd Resler wrote: > I want to have an alert pop up to let the user know their session is about to > expire. Would the best approach be to do a timer in Javascript or check it > in PHP. I'm storing session data in a MySQL database so I can know when a > session will expire. If I check it through PHP will the session expiration > refresh when I check it? > > Thanks! > Floyd Floyd: If this was my problem, my solution would be: 1. A PHP script that recorded (via MySQL) the date/time when the user successfully accessed something private (i.e., password protected). 2. The next time the user requested protected-access again, I would have the script look at the last time the user accessed this data and see IF the time period between accesses (then and now) exceeded an established time limit. If so, then deny access. If not, then reset the timer and allow access. That's the way it would work on the server-side. However, the server-side really has no efficient way to notify the user their session is "about" to expire -- instead that should take place client-side and without question, you'll need a client-side JavaScript timer. The client-side timer simply preforms a count-down and notifies the user when their session is about to expire. The important thing to realize here is that the client-side and server-side scripts have no communication between each other nor is any needed other than when to start the count-down. The two scripts are separate, but are working in "apparent" concert. The server-side script will be the ultimate decider of IF the user's session has timed out or not. The client-side script only notifies the user of the count-down and nothing else. HTH's tedd PS: Arby's? _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Seeking a scheduling algorithm
Hi gang: Does anyone have a resource, or better yet code, to solve the scheduling problem described below? Let's say you have a week calendar that has openings between 8:00am to 5:00pm for Monday through Friday (40 hours). Then you have an assortment of appointments that must be scheduled into the week calendar. Some of the appointments are simply a one hour per week, while others may be two, three, four, or five times per week and each appointment for an hour or more (up to eight hours). The problem is, knowing what appointments (i.e., twice a week for 2 hours, three times a week for one hour, etc.) must be scheduled for the week, what is the most efficient way to schedule these appointments into that week? The most efficient way is defined as scheduling appointments with little, or no, gaps in between appointments. For example, four one-hour appointments on Monday between 8:00am to 12:00pm is better than four one-hour appointments spread out between 8:00am to 5:00pm. Anyone have any solutions, ideas, resources, code? Thanks, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking a scheduling algorithm
_ t...@sperling.com http://sperling.com On Jul 14, 2012, at 6:32 PM, Bill Guion wrote: > On Jul 14, 2012, at 4:53 PM, php-general-digest-h...@lists.php.net wrote: > >> From: Tedd Sperling >> Does anyone have a resource, or better yet code, to solve the scheduling >> problem described below? >> -snip- >> The problem is, knowing what appointments (i.e., twice a week for 2 hours, >> three times a week for one hour, etc.) must be scheduled for the week, what >> is the most efficient way to schedule these appointments into that week? > > > Tedd, > > There is an old general rule that the most time efficient way to schedule is > to put the "big" time requests on the schedule first. In this case, that > would mean schedule all five times a week requests first, then the four times > a week, then the three times a week. The two hour requests should be > scheduled next: three times a week and twice a week can be scheduled at the > same time. Then fill in the rest with the one hour requests. > > Hope that makes sense. > > -= Bill =- Bill: Yes, that makes sense and that has been my first-blush approach to the solution to this problem. It's a bit like filling a paper bag at checkout, or filling a moving van -- you put in the biggest items first and then fill the empty spaces with smaller and smaller items. I was just thinking the problem is not new and perhaps there is an algorithm laying around somewhere. For example, an automated "solution" for the Tetris game might be a good match. People have proposed the Bin Packing Problem and looks interesting. Likewise, the knapsack proposal is interesting, but it leaves stuff behind, which is not possible in the problem I'm trying to solve. If I have too many appointments, then I simply hire more people to solve the overbooking problem. This problem is: 1. Fill all the open times efficiently with bookings. 2. If you run out of open times, then open a new week and fill it similarly. Like I said, this is similar to filling a paper bag at checkout -- when the bag is filled (as efficiently as possible), then get another bag and repeat. I claim if you know the size and number of items before-hand, then you should be able to optimize both: a) the filling of each bag; b) and minimize the number of bags you need. Maybe that's a better way to describe this problem. > A closed mouth gathers no feet. LOL -- I should remember that. Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On Jul 16, 2012, at 4:16 PM, Ramiro Barrantes wrote: > Hello, > > I am making an application using PHP/Javascript/mysql and had a question. > > Sometimes I need to use javascript to fill a drop down box based on the value > of a previous drop down box. However, the information to fill the latter is > stored in mysql and can be a lot, what I have been doing is that, using PHP, > I create hidden fields with all the possible information that might be needed > to fill the second drop down. > > For example, the user chooses a bank from a drop down, and then a list of > clients is displayed on the following drop down. I use PHP to read all > clients from all the banks and put that as hidden fields on the html page. > It is very cumbersome. > > I do not want to read the database (which changes dynamically) from > javascript directly due to confidentiality and because a lot of care has been > taken to create the appropriate queries with checks and protect misuse of > the information using PHP. > > My questions are: > 1) Do people just normally use hidden fields to store possible information to > fill the drop downs? > 2) any suggestions? > > Thanks in advance, > Ramiro > Ramiro: The subject line of "Creating drop-down menus" is misleading -- here is what a "drop-down menu" is: http://sperling.com/examples/new-menuh/ http://sperling.com/examples/menuh/ And similarly, a "fly-out menu": http://sperling.com/examples/menuv/ What you are describing is simply a self-updating selection control, like this: http://php1.net/a/zipcode-states/ The description and code is there. To the PHP gang: As for the discussion re jQuery and such, there's no need -- it was not used in this demo. IOW, no jQuery was harmed. I am not against jQuery, on the contrary I think it's great, but it's not always needed for client-side functionality. As I see it, there is no need for a sledgehammer to drive a thumb tack. Please realize that all controls (input, textarea, options, selections, checkboxes, radio buttons, multi-options, etc.) can be handled this fashion. This is not your father's limited server-side php, but rather a coupling of both server-side and client-side languages to provide a more desktop-application-like user experience. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What do you call the end-user?
Hi gang: I can't wait for tomorrow -- so here's my off-topic post today. First question: What do you call the people who ultimately use your code? I call them the "end-user", but others have stated other terms, such as "customer" or "user". Second question: Are you concerned with their ("whomever") experience in using your code? This question transcends your code working correctly, accurately, and securely -- no need to comment on those aspects. But rather more specifically do you consider how easily your "whomever" can use your work efforts? As you may have guessed - I just attended a UX conference and they provide an interesting perspective on UX. I was wondering how php developers typically address the subject. Cheers, tedd t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What do you call the end-user?
On Jul 19, 2012, at 1:54 PM, "admin" wrote: > My goal in life has been to develop the ultimate portal that thinks for you > and less dependent on your interactions. I am close to finishing a learning > module that learns from your interactions and navigates according to your > past history. But that is for another time If not now, when? It sounds very interesting. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On Jul 19, 2012, at 1:50 PM, Daniel Brown wrote: > >As an aside on the subject of jQuery, our very own Jay Blanchard > has written a comprehensive book on the topic entitled "Applied > jQuery: Develop and Design": > >http://links.parasane.net/92xb > Just bought it -- thanks. I'll add it to my other three jQuery books Always support the people on this list. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Stats
Hi gang: Do we have anything a bit more up to date than this? http://php.net/usage.php That's five years out of date! Also, the links out don't really provide anything useful -- they are either dated, show vested interest (i.e., want money), or they provide information not relevant to php. For example, "Objective C overtakes C++" I find interesting, but it doesn't relate to PHP. As such, I have a difficult time figuring out what web languages are the most wide-spread. So, do we have something better? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 8, 2012, at 5:41 PM, Jim Giner wrote: > On 8/8/2012 11:24 AM, Ansry User 01 wrote: >> I am setting the _SESSION variables in one of my file, but whenever I leave >> the php page session variables are not accessible. Not sure what I need to >> do additionally other then defining _SESSION[]. >> Any pointer. >> > You must make it a habit to start each script with > > session_start(); > I like this way: if (!session_id()) { session_start(); } Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 9, 2012, at 5:16 PM, Jim Lucas wrote: > You are relying on PHP's loose typing. This is a poor check. > > session_id() returns a string, not boolean. > > You should do this instead. > > if ( session_id() === '' ) > > > > -- > Jim Lucas Thanks Jim -- you're right. What about? if (!defined(SID)) { session_start(); } Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 10, 2012, at 11:45 AM, Tedd Sperling wrote: > On Aug 9, 2012, at 5:16 PM, Jim Lucas wrote: >> You are relying on PHP's loose typing. This is a poor check. >> >> session_id() returns a string, not boolean. >> >> You should do this instead. >> >> if ( session_id() === '' ) >> >> >> >> -- >> Jim Lucas > > Thanks Jim -- you're right. > > What about? > > if (!defined(SID)) > { > session_start(); > } Before you answer, the "(!defined(SID))" is over 50 times slower than "( session_id() === '' )" Your way is better. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: > Hi. My question will maybe out of topic, I'm sorry. > How can you know that one way will be much slower than other one? I mean, how > can I learn which function is faster before I test it? Ege: No your question is on topic. This question should be asked on the list, so I'll present Q:A instead of answering privately http://www.webbytedd.com/b/timed1/ The code is there -- if you have questions, please post them to the list. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 13, 2012, at 10:59 AM, Robert Cummings wrote: > On 12-08-10 04:42 PM, Tedd Sperling wrote: >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin wrote: >> >>> Hi. My question will maybe out of topic, I'm sorry. >>> How can you know that one way will be much slower than other one? I mean, >>> how can I learn which function is faster before I test it? >> >> Ege: >> >> No your question is on topic. >> >> This question should be asked on the list, so I'll present Q:A instead of >> answering privately >> >> http://www.webbytedd.com/b/timed1/ >> >> The code is there -- if you have questions, please post them to the list. > > Ted, > > Please see the current signature for microtime(): > >mixed microtime ([ bool $get_as_float = false ] ) > > The optional paramter was added in PHP 5.0.0. I think it's safe to update > your habits :) > > Cheers, > Rob. Rob: Fixed. Thanks -- my habits are always in a state of being updated -- just ask my wife. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 14, 2012, at 11:01 AM, Robert Cummings wrote: > > I'm not sure if you're making a joke, but your changes have no effect. You've > merely explicitly stated the optional parameter's default value. What I had > meant was to change the following: > > > $starttime = microtime(); > $startarray = explode(" ", $starttime); > $starttime = $startarray[1] + $startarray[0]; > > ?> > > To the following :) > > > $starttime = microtime( true ); > > ?> > > Cheers, > Rob. Rob: Again thanks. Sorry, I totally missed your point. In my "defense" I commonly use the value returned from microtime() as a string and not as a float. The code that followed my "microtime( false );" demo broke the string and recombined it into a float. So, when you said: Please see the current signature for microtime(): mixed microtime ([ bool $get_as_float = false ] ) I looked at that and said to myself, "Oh, I need to define it as 'false' " because I was using it as a sting. I completely overlooked your point that microtime() could return a float and thus no need to work with it as a string -- duh! The demo is fixed (I think): http://www.webbytedd.com/b/timed1/ Thanks, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
Andrew: Your points are well taken -- thanks. However, my only concern is given this: > for($i=1; $i < 1000; $i++) >{ >if (!defined('SID')) > { > echo __LINE__, '::session_start()'; > session_start(); > } >} The php manual ( http://us3.php.net/manual/en/function.session-start.php ) First Note states that session_start() must be called *before* anything sent to the Browser. So, to rewrite your code -- for($i=1; $i < 1000; $i++) { if (!defined('SID')) { session_start(); echo __LINE__, '::session_start()'; } } -- should work better, right? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 15, 2012, at 4:42 PM, Andrew Ballard wrote: > On Wed, Aug 15, 2012 at 3:24 PM, Tedd Sperling wrote: >> The php manual ( http://us3.php.net/manual/en/function.session-start.php ) >> >> First Note states that session_start() must be called *before* anything sent >> to the Browser. >> >> So, to rewrite your code -- >> >> for($i=1; $i < 1000; $i++) >> { >> if (!defined('SID')) >> { >> session_start(); >> echo __LINE__, '::session_start()'; >> } >> } >> >> -- should work better, right? >> >> Cheers, >> >> tedd > > > -snip- > However, due to the nature of your test page you are still > sending output from the first loop before you call session_start() in > the second loop. Duh! Too many brain surgeons working on this brain! In the real world neither of us would have made those mistakes. It is only when we try to make things simple do we over complicate. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP session variables
On Aug 15, 2012, at 4:13 PM, Robert Cummings wrote: > > I only pointed it out because I used to do exactly the same thing :) > > Cheers, > Rob. Thanks, I was starting to feel pretty dumb. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need to have form protection techniques
On Aug 17, 2012, at 10:09 AM, Daniel Brown wrote: > On Fri, Aug 17, 2012 at 12:05 AM, Ansry User 01 > wrote: >> I need to know the forms validity techniques for Php. > >This will probably take a while to absorb, so you may need to > revisit this page several times: > >http://oidk.net/php/know-the-forms-validity-techniques-for.php > > -- > > Network Infrastructure Manager > http://www.php.net/ I would also add: http://phpsecurity.org Chris has written an outstanding book on php security -- well worth the read/cost. http://www.amazon.com/Essential-PHP-Security-Chris-Shiflett/dp/059600656X Less than $20 -- you can't beat that. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need to have form protection techniques
On Aug 17, 2012, at 10:42 AM, Robert Cummings wrote: >>> On Fri, Aug 17, 2012 at 12:05 AM, Ansry User 01 >>> wrote: I need to know the forms validity techniques for Php. >>> >>>This will probably take a while to absorb, so you may need to >>> revisit this page several times: >>> >>>http://oidk.net/php/know-the-forms-validity-techniques-for.php > > No tedd, I'm sorry but the info in the link above is pretty much perfect. > > Cheers, > Rob. Oh, to be serious on this list on Fridays is lost cause. I keep forgetting Fridays are like April 1. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple forms one page
On Aug 27, 2012, at 12:08 AM, Rosie Williams wrote: > > Hi all, > I am a newbie to PHP. I have several php forms which were originally on > separate pages now included in the one page. Each form had the following code > in it: > function mysql_fix_string($string){ if (get_magic_quotes_gpc()) $string = > stripslashes($string);return mysql_real_escape_string($string);} > function mysql_entities_fix_string($string){ return > htmlentities(mysql_fix_string($string));} > However I am only able to include it in one of the forms on the new page with > multiple scripts due to the fatal error that I can only declare the function > once. So for testing I have commented these lines out of the other scripts. I > need to know what the security implications of this are? Do the scripts that > do not contain these lines run without it or is it included automatically > every time the database is accessed regardless of which script is accessing > it? > If not how do I deal with it? > thanks in advanceRosie My advice -- place your common functions into one file (i.e., functions.php) and: include_once("includes/functions.php"); At the start of every script that needs any of the functions contained therein. As for rolling several forms into one, here are some of the ways I do it: http://sperling.com/php/step/ http://sperling.com/php/submit/ Cheers, tedd PS: If anyone see's anything in error, please feel free to correct me. As a very talented harmonica player once said "Sometimes I suck and sometime I blow." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error breaking in and out of php into html code
On Aug 26, 2012, at 1:36 PM, Ashley Sheridan wrote: > Well, it turns out that I'm just an idiot... > -- > Thanks, > Ash That was easy -- anyone of us could have told you that. :-) Cheers, tedd PS: We all have our time in the barrel. _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load rtf file
On Sep 3, 2012, at 1:23 AM, John Taylor-Johnston wrote: > I have a big giant RTF file. I could convert it to plain text. BUT can PHP do > it for me? Hell, even M$ can't do it! I have tons of old Word RFT files that were orphaned by the installation of a newer of M$ Word. The upgrade actually deleted older versions of Word and then would not open the older files because of security concerns (they were create by an older version, duh). It was a nightmare -- as a result, I lost years of business correspondence. Now I make z text version of every document I write. If I wanted to get those old files back, I will have to set up an older computer, reinstall the older version of Word and then transfer those files, convert them to text, and bring them back. That's a lot of work because I trusted M$ to respect older files, but they don't. In short, don't trust M$. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load rtf file
On Sep 3, 2012, at 12:56 PM, Matijn Woudt wrote > > Just a side note tedd, couldn't you just open those RTF files with > wordpad? IIRC it supports RTF and plain text (even in Win7) > > - Matijn Maybe if I was on a Windoze machine, but I'm on a Mac. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Programmers and developers needed
On Sep 13, 2012, at 3:45 AM, agbo onyador wrote: > Hello there! We are looking for programmers and developers to create a > world wide system. Your comments are welcome. Wow! I'm looking for world wide money. tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Day after Friday
Hi gang: I know it's the Day after Friday, but I'm asking a off-topic question anyway -- sorry. Normally, I teach a PHP class at the local college, but it got canceled (don't ask why) -- now I'm teaching Java. So, can anyone recommend a Java list that is similar to this list? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Day after Friday
On Sep 22, 2012, at 3:59 PM, Paul M Foster wrote: > On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote: > >> Hi gang: >> >> I know it's the Day after Friday, but I'm asking a off-topic question anyway >> -- sorry. >> >> Normally, I teach a PHP class at the local college, but it got canceled >> (don't ask why) -- now I'm teaching Java. >> >> So, can anyone recommend a Java list that is similar to this list? > > Off off topic... > > Who the hell cancels a PHP class? Do they not realize damn near the > whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad > nauseum, not to mention Symfony, CakePHP, Code Igniter, etc. > Administrators! Ach! > > Paul Paul: The class was canceled by administration and they have absolutely no conception of the technology and scope that PHP brings to the table. In fact, they were so opposed to PHP that when I first started teaching there they had PHP removed from their servers because of security concerns. So, for me to teach PHP, they were forced to install PHP/MySQL. Now that you asked, here's the story about my PHP class. The college moved the entire CIT (Computer Information Technology) department five miles from the downtown campus, where it has always been, to the new West campus. It's a nice campus, but no Macs -- admin said Mac don't meet their ROI requirement, but that's another story. Of course, most students don't have transportation and there is no established public transportation from main campus to west campus -- that's not good. Knowing that the students were going to have problems with transportation and that would result in a reduction in class sizes, the administration agreed to allow "smaller than norma"l classes for the Fall semester. Furthermore, the administration agreed to allow registration to be for a longer period than normal, namely from a couple of weeks before the semester started to a week after the semester started. Everything sounds ok, right? My PHP class had six students register two weeks before the class started. I expected, as is custom, to pick up a couple of students after the semester started thus exceeding the minimum number of student required. Furthermore, I agreed to teach the class at a reduced rate if there wasn't a sufficient number of students attending. BTW, administration had not made a determination as to exactly what the minimum class-size should be -- keep in mind, they only had two years to decide and these things take time. So what happened? Well we (the teachers) have a new contract and in that contract is a provision that allows for a reduced class size IF the teacher agrees to teach it at a reduced rate -- which I agreed to do. However, administration became confused as to how to pay a full time teacher IF they taught an undersized class. So, their solution was to cancel ALL under sized classes before the semester started. That way there would be no confusion as to what to pay. Now, in my case I am the only teacher to teaches PHP, so there would be no full time teacher that might teach it. I am also an adjunct (part time) teacher and as such there is no confusion as to my pay. I am simply paid hourly and a reduced class size would result in my rate being reduced. So, there was absolutely no reason what-so-ever for my class to be cancelled. Leaps and bounds of illogic. This is just another example of how administration makes decisions. It would be nice if administration decisions were made with respect to "what is best for the student" as compared to this type of nonsense. Cheers, tedd _ t...@sperling.com http://sperling.com . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Day after Friday
On Sep 23, 2012, at 10:17 AM, Samuel Lopes Grigolato wrote: > Independent of programming language, good teaching skills will lead to > self-taught developers with a bunch of best practices under the hood. I hope > you are such a good teacher =). We need not PHP or Java developers, we need > good and creative designers that can adapt to new tools. > > One language is only a path among others with the same goal, software with > quality. Remember Brooks (1986, yes, that old!), the real problem (essence of > software engineering) is capture business requirements as specifications, and > not translate specifications to software. > > The point is, you, as a teacher, has a wider responsibility, you need to find > and incentive creative talents, not just teach one or another native function. > > Cheers. > Samuel. I think I have a handle on that. What I tell my students is "I can't teach you computer programming, it's you pounding keyboards and seeing how the computer responds is what teaches you coding." I also show them the similarities between different languages thus giving my students the confidence to develop code in any language. After all, programming languages are constantly changing (or dying) and they all are getting closer together in syntax and function. IMO, in the future, we'll have one common computer programming language. In short, I'll give them the tools, but it is up to them to implement them. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Day after Friday
On Sep 23, 2012, at 6:28 PM, Paul M Foster wrote: > On Sun, Sep 23, 2012 at 09:33:33AM -0400, Tedd Sperling wrote: >> >> It would be nice if administration decisions were made with respect to >> "what is best for the student" > > You know, I never had much respect for academia... Academia has it's place, but it often takes someone smarter to figure out what that is. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Here's my rounding
On Sep 28, 2012, at 9:27 AM, Jim Giner wrote: > On 9/28/2012 2:11 AM, Simon J Welsh wrote: >> On 28/09/2012, at 6:08 PM, Chris Payne wrote: >> >> I would use something similar to $rounded_number = ceil($test2/1000)*1000; >> --- >> Simon Welsh >> Admin of http://simon.geek.nz/ >> > From my days as a math major, rounding doesn't always go up - it goes to the > nearest level that you have indicated. As Simon shows you, you want to ceil > to always go up, and floor to always go down. Neat function names > actually... :) A more accurate rounding is HALF-EVEN -- first Google search produces: http://www.crazysquirrel.com/computing/java/basics/rounding.jspx I did this with php several years ago, namely: http://www.webbytedd.com/bbb/rounding/ I leave it to the community to develop the code. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Friday - Return of Brain Teasers
On Oct 7, 2012, at 5:05 PM, Matijn Woudt wrote: > On Fri, Oct 5, 2012 at 7:43 PM, Daniel Brown wrote: >>About five-and-a-half years ago, we had a brainteasers thread >> going on[1]. Last year it was briefly resurrected[2], and both times >> got some good content and dialogue going. So I'd like to reprise the >> thread in 2012, as well. Those of you connected to me on Facebook >> (parasane) or Twitter (@oidk) might already have seen it, but a simple >> one to get things rolling: >> >> >> >> -- >> >> Network Infrastructure Manager >> http://www.php.net/ >> > > It somehow seems the creative ones on this thread have been gone... Or they are occupied with other things. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to click download button,and run 2 tasks downloading a file and show number of downloads(ajax)simultaneously?
On Oct 14, 2012, at 7:41 AM, Negin Nickparsa wrote: > I wanted to refresh the download count when clicking the button first is it > possible? Yes, it is possible. The following is an example of a server-side php script refreshing a Web page via a javascript client-side action: http://php1.net/a/zipcode-states/ The action is triggered by simply using the selection control, which in turn activates an onchange javascript routine that causes a slave php script to run retrieving data from a database returning the data thereby causing an ajax script to update the selection control. All the code (html, javascript) is there except for the php script, which should be trivial to write. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Java guru?
Hi gang: Anyone here a Java guru? If so, please contact me privately -- I have a question. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch - Case Statement Questions
On Nov 19, 2012, at 2:46 PM, Stuart Dallas wrote: > On 19 Nov 2012, at 19:35, Tim Streater wrote: > >> On 18 Nov 2012 at 14:44, Jim Giner wrote: >> Just so. Perhaps those who are not grasping the point could re-read their >> copy of "The Elements of Programming Style" by Kernighan and Plauger where >> this sort of issue is covered. > > And of course, nothing is allowed to have changed since 1978! Using a switch > in that manner is normal for me. Should I change my style simply because you > don't agree with it? If so, why don't you change your style because I don't > agree with that? Code is art; there is no "right" way to do it. Can code be > shown to be more efficient, elegant, faster, cleaner? Yes. Right or wrong? No. +1 for me as well. Publish data -- January 11, 1976??? This may be your father's book (or grand-father in my case). So, don't confuse me with old facts -- buy new ones. Just look to other languages (such as JAVA) for variations in switch. I think php got it right. After all, while(), if(), do/while() and even for() work around the concept of true -- why not switch? Cheers, tedd PS: We've had this conversation many years ago (but not as far back as 1976). _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorry bout that...
On Dec 21, 2012, at 8:22 AM, Steven Staples wrote: > I would like to let everyone know that the world didn't end this morning > like it was supposed too. It didn't! You couldn't prove that by me -- I'll ask my wife. She knows everything. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorry bout that...
On Dec 21, 2012, at 11:39 AM, Steven Staples wrote: >> You couldn't prove that by me -- I'll ask my wife. She knows everything. >> >> Cheers, >> >> tedd > > And this will be the last we hear of Tedd... LOL Well... she did say "Don't worry about -- go shopping." So, I'll be leaving now. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Strange string stuff -- maybe everything is ending...
Hi gang; I just ran into something I have never had a problem with before. Here's the code: --- start of code $topic = ''; while($row = mysql_fetch_array($result)) // pulling stuff from a database { $topic .= $row['category'] . '~'; // adding a delimiter between categories } $str_length = strlen($topic); if($topic[$str_length-1] == '~') { $topic[$str_length-1] = ''; // remove last ~ delimiter } echo($topic); // this result is used in an AJAX script --- end of code Now, when the result is displayed (i.e., echoed) to Javascript routines running in Safari and FireFox, everything is OK. But when the result is displayed on IE, the "end" of the string causes problems with the exact same javascript routine as used above. Now, I realize that I have altered the string by removing the last character and I have not shortened the string to reflect that, but I never thought it would cause any problems. Would someone please enlighten me as to why this would work in Safari, FireFox, but not in IE? Cheers, tedd PS: Also, please don't beg the answer by saying "It's IE -- what do you expect?" _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 21, 2012, at 5:05 PM, Ken Robinson wrote > A much easier way to do this would be to use a temporary array and then > explode: > > $tmp = array(); >while($row = mysql_fetch_array($result)) // pulling stuff from a > database >{ >$tmp[] = $row['category']; >} > >$topic = explode('~',$tmp); // put the delimiter between each entry >echo($topic); // this result is used in an AJAX script > > > No more worrying about whether the delimiter is the last character. > > Ken Ken: Slick -- I like it. But, the question remains -- if you make the last character in a string a '' (or null), then what's the problem with doing that? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 21, 2012, at 4:58 PM, Jim Giner wrote: >> > Never realized that you could address a string as an array of chars, which > you are doing. Could that be the issue? Or did I learn something new? Or > should you have used substr to remove that last char? Jim: I guess you learned something new -- that's good. A string is just a "string" of chars. As such, if you define: $a = "tedd"; then: $a[0] is 't'; $a[1] is 'e' $a[2] is 'd' $a[3] is 'd' The only confusing thing here is the length of the string -- in this case the length of this string is four, but $a[4] has not been defined. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 21, 2012, at 5:20 PM, Volmar Machado wrote: > What is the result in FF? And on IE? (the echoed string) That's the problem, it's different. If the last char in a string is set to null, then it causes JavaScript routines running under IE to behave differently than the exact same JavaScript routines running under Safari or FireFox. This was something I never expected. However, the web industry has had to deal with IE oddities for many, many years -- the problem remains and it's called IE. Remember, M$ always has a better idea. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 21, 2012, at 5:27 PM, Jim Giner wrote: > From what I do know, there shouldn't be an a[4]. > In any case, let's assume that there is a bug in the string logic that you're > using. Why not just use substr? > > $topic = substr($topic,0,-1); and On Dec 21, 2012, at 6:10 PM, Nathan Nobbe wrote: > Neat idea Tedd, but judging by a quick test, I don't think changing the > value of the string is entirely supported though that notation. > > php > $str = 'blah'; > php > $str[3] = ''; > php > echo $str . PHP_EOL; > bla > php > echo strlen($str); > 4 I'm not looking for a solution, but rather pointing out something I never encountered before. I would have never thought that a string echoed by a PHP script to be used in a JavaScript routine would depend upon what Browser it is run on. That seems odd. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 21, 2012, at 8:06 PM, Jim Giner wrote: >> That actually makes sense tho. Afterall, a string is truly only one memory >> allocation whereas array elements are basically multiple vars having the >> same name. So - how can you unset one char in a string? It depends upon the language -- while it is true that the start of a string is located at a memory address, the chars of the string are identical to the chars in an array. As such, you can view a string as an array. Each index is representative of a char (one byte) in the string. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
On Dec 22, 2012, at 7:58 AM, tamouse mailing lists wrote: > A bit of an example to shed a little light? > -snip- > Not knowing IE really at all, nor it's JS engine, it's entirely > possible that a null character in a string causes it to have problems. That's the explanation I was looking for -- thanks! Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested loopa
On Dec 26, 2012, at 10:09 AM, Jim Giner wrote: > While I fully understand the purpose of the do...while construct, I just > never get used to seeing it used. (in other langs I had to deal with a > 'repeat...until construct and dis-liked that also). I pretty much know if > I'm going to have to deal with a "run at least once" when I'm coding and > therefore code appropriately, altho I don't know in what ways I've handled it > at this very moment. > -snip- > To me - so much easier to comprehend at first glance. As soon as my eye > comes to a block of code starting with a conditional like 'while', I readily > see what makes it tick. Again I see the potential usefulness of doing it the > other way as you did in your example, but in your case there wasn't a need > for using 'do...while' since you structured it so that there was never a case > where you had to force the loop to happen regardless of conditions. I too used while's instead of do's for the same reason. However, in my class I had a student show be the light (one can always learn from beginners). Think of it this way, you travel into the code knowing that at some point you're going to repeat the block of code IF a condition is going to be met within the block of code. With that consideration, the 'do/while()' works. Using just a 'while()' for everything means you must determine the what the truth of the 'while()' is going to be AND set that value before the loop. Whereas, using a 'do/while()', you don't need to set the truth until the block of code has been implemented AND at that point determine the truth of the block of code. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
On Jan 3, 2013, at 11:49 AM, Marc Guay wrote: > I just ran this: > > if (($a = "foo") || ($b = "bar")){ >echo $a."".$b; > } > > and it only spat out "foo" so I'm guessing things have changed. :) > > Marc Marc et al: I joined late into this conversation, so I may be missing the point, but you want to discus strangeness try this: $b"; } else { echo 'Neither are populated'; } ?> However, the above practice of using one '=' is questionable -- the following is better. $b"; } else { echo 'Neither are populated'; } ?> Comment out the variables to see how things work. Also change the number of pipes to see how things change. To the more accomplished programmers reading this, here's a question: What's the difference between using one pipe or two in an 'if' statement? :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
On Jan 3, 2013, at 12:09 PM, David OBrien wrote: > From what I understood about || is once it sees a true the whole statement > is regarded as true so nothing else following matters so PHP ignores > everything in the conditional after it evaluates as true... > and once it sees a false the whole statement is regarded as false so > nothing else following matters again You are correct with regard to the double pipe ( || ). The double pipe means simply that if the first expression is true, then the second expression will not be considered. Whereas, a single pipe ( | ) means that both expressions will be evaluated. Now, I am not sure as to where that would mean anything. Can anyone provide an example where using a single pipe would produce different results than using a double pipe? IOW, why is there a difference? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear Page2
On Jan 5, 2013, at 3:11 PM, Silvio Siefke wrote: > On Sat, 05 Jan 2013 17:21:05 + > Ashley Sheridan wrote: > >> If the pages are already written, why do you want to start changing >> the way they've been built? > > 1.) All websites are created manually. (nano + html/css Tags) > Not mine. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear Page2
On Jan 5, 2013, at 4:24 PM, Silvio Siefke wrote: > > What should me say this two words? You not use nano, ok. Editors enough > on earth. Or you not write manually? Then share the way! Or use a CMS? Silvio: You said -- > 1.) All websites are created manually. (nano + html/css Tags) -- and I replied "Not mine". In other words, some of my web-sites are NOT created manually. They are dynamically generated from user input. For example: http://ancientstones.com For the exception of the static First page, FAQ page, and Contact page, all other pages are generated from user input/direction. I don't use nano (I don't even know what that is), but what I do is to create pages that pass W3C compliance and follow "best" practices. From what I've gathered from most frameworks I've reviewed, they have problems (similar to ASP) in mixing different languages in ways such that compliance with W3C and accessibility issues are difficult, if not impossible, to achieve. Even CMS's have difficulty with compliance and accessibility issues because of the lack of knowledge of the user/client. I have clients who insist on CMS's, but then are clueless as to user issues and difficulties.. So, where does that leave a "Web Developer?" It leaves them with the responsibility to learn and apply what they learned to their craft. Is there an easy way out, such as to use a certain framework, or CMS, or other such attempts at minimizing the work involved? The answer is a simple "No". Instead, you have to spend every waking hour learning and applying that knowledge with openness to the possibility that you still don't understand the problems involved -- it's a never ending battle to educate yourself. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear Page2
On Jan 6, 2013, at 12:52 PM, Silvio Siefke wrote: > On Sun, 6 Jan 2013 11:36:39 -0500 > Tedd Sperling wrote: >> So, where does that leave a "Web Developer?" It leaves them with the >> responsibility to learn and apply what they learned to their craft. >> Is there an easy way out, such as to use a certain framework, or CMS, >> or other such attempts at minimizing the work involved? The answer is >> a simple "No". > > I simply asked a question, nothing more, nothing less. I looked for an > alternative. I do not need a web developer. I'm not a web developer. > I manage a few sites, most of my Customers are hosting customers. No offense meant, but therein lies the problem. Two fold: 1. You asked a question without the intent to learn and practice. 2. By your own admission, you are not a web developer and as such you cannot use our advice. This is similar to me asking about brain-surgery -- I don't know much about it, but I would be very reluctant to operate. You also said: > I'm just wondering, why write an email to the matter is insignificant. On that point, I must agree -- I probably should not have answered. I should have seen you were having difficulties understanding what was being offered and passed on my contribution -- my apologies. I also realize there is a language problem here -- while I cannot speak your language, what you say in mine and my replies, may be misinterpreted -- but in any case, no offense was meant. I wish you well. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Strip emails from a document
Hi gang: I thought I had a function to strip emails from a document, but I can't find it. So, before I start writing a common script, do any of you have a simple script to do this? Here's an example of the problem: Before: "Will Alex" ;"Moita Zact" ;"Bob Arms" ;"Meia Terms" ; After: ale...@cit.msu.edu za...@cit.msu.edu ar...@cit.msu.edu term...@cit.msu.edu Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strip emails from a document
On Jan 26, 2013, at 12:20 PM, Daniel Brown wrote: > >It's imperfect, but will work for the majority of emails: > > function scrape_emails($input) { > > preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui",$input,$matches); >return $matches; > } > ?> It works imperfectly enough for me. :-) Here's the result: http://www.webbytedd.com/aa/strip-email/index.php Thanks to all. Cheers, tedd PS: Yes, 'extract" is what I meant and more correct than 'strip' as I said. _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strip emails from a document
On Jan 26, 2013, at 12:48 PM, shiplu wrote: > What is your input? > Check my first email in this thread. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is header() malfunction due to PHP5.3.3 -> 5.4.11 transition?
On Feb 9, 2013, at 2:00 PM, Jonathan Eagle wrote: > I'm having a problem with a very straightforward routine; Jonathan: No offense to your routine, but you may want to review this: http://sperling.com/php/authorization/log-on.php If anyone finds an error, please post. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Affordable low-fee e-commerce - DIY?
On Feb 18, 2013, at 1:26 PM, George Langley wrote: > Hi all. Am wanting to build a site where people can donate $1.00 but is not > for charity or other non-profit per se. So if I use PayPal, with their 2.9% + > .30 per transaction fee, that equals .33 cents for each dollar - that's a > full third of the amount the people would be giving. Credit cards appear to > be similar, with some percantage and about .22 cents per transactions. > Am wondering what other options I'm missing, that won't take such a chunk out > of the low price? Is it easy enough to code to some other API for free (or at > least cheaper)? > Thanks. > > > George Langley > Interactive Developer I don't have any problems with people paying me via PayPal -- PayPal provides a service and they deserve a piece of the action. In fact, I never have problems with people donating $5 to my cause (me) via my site -- and it happens. For example, I had one guy donate $100. I'm waiting for someone to better that. :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if (empty versus if (isset
On Feb 20, 2013, at 9:10 AM, Jim Giner wrote: > Basically it tells a savvy programmer whether or not his logic has caused the > var in question to "exist". Many times it is important simply to know that, > not what the var contains, which can lead to an error in processing. > > The isset() will tell you that "yes, I have this variable", letting you then > correctly interpret the contents. If a $_POST var is not set (meaning the > user made no input to it), the use of empty() will insist on telling you that > the var is empty even tho it really was not provided by the user (assuming > that you don't get an error msg for having an invalid index in the POST > array). > > They seem to be needlessly redundant, but in fact do provide knowledge for > those seeking it. > That's one of the reason why I recommend using a Ternary Operator to check the POST array, such as: $submit = isset($_POST['submit']) ? $_POST['submit'] : null; That way, you never encounter an error looking for something that is not there. Cheers, tedd t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Feb 19, 2013, at 7:57 PM, John Taylor-Johnston wrote: > I cannot find button2 in phpinfo() when I click it. I was hoping to find a > $_POST["button2"] value. > What am I doing wrong? > > onclick="formSubmit()"> > > I really wanted to use a button to pass a different condition than a type="submit"> Lot's of different ways to pass values via forms. Try using : Then check the button2 value via a: $button2 = isset($_POST['button2']) ? $_POST['button2'] : null; That's one way -- there are many more. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple="multiple"
On Feb 18, 2013, at 7:54 PM, John Taylor-Johnston wrote: > I am capable with . (I suppose I did it correctly? > :p ) > But I haven't the first clue how to parse a and multiply > select name="DPRtype". > Would anyone give me a couple of clues please? :) > Thanks, > John John: A clue? How about an example? See here: http://sperling.com/php/select/index.php Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Feb 20, 2013, at 2:31 PM, Stuart Dallas wrote: > You were given the answer, did you not try it? > > Starting with the code in your original post: > > 1) Change the type to submit. > 2) Remove the onclick. > 3) Job done! > > -Stuart Sometimes you just can't help. > Sent from my leaf blower :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding an Address
On Feb 28, 2013, at 12:36 PM, Floyd Resler wrote: > I have a project where my client would like to find the nearest street > address from where he current is. Getting the longitude and latitude is easy > enough but I'm having a hard time finding out how to get the nearest house. > I have found a lot of solutions for addresses maintained in a database but > these addresses won't be in a database. I thought about just querying Google > for each longitude and latitude within in a small circle but my math skills > are nowhere near good enough to accomplish that. Anyone have any ideas? > > Thanks! > Floyd What about using zip codes? Like so: http://php1.net/a/zipcode/ Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
On Mar 2, 2013, at 11:25 AM, Jay Blanchard wrote: >> No - Tedd is old. The rest of us are just Spring chickens. Hey, let's watch that... a, what? What the hell was I saying??? Awww .. forget it. Did I tell you about when I programed with rocks? That was before someone invented the absence of rock (a really abstract idea) and then things got mondo weird. We were finally able to build things that didn't always look like pyramids. You see, we had been stuck in Oh Oh Pyramids days, which we called OOP. The more things change... Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
On Mar 2, 2013, at 11:26 AM, Stuart Dallas wrote: > On 2 Mar 2013, at 16:25, Jay Blanchard > wrote: > >> No - Tedd is old. The rest of us are just Spring chickens. > > Speak for yourself, I'm an autumn turkey! > > -Stuart What's this "autumn" nonsense? tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Introduction ... !
On Mar 2, 2013, at 2:20 PM, tamouse mailing lists wrote: > See, you can't really call yourself old until that's pooping and cramping... That reminds me -- a couple of my older friends and I were discussing getting old. One friend said "At 8:00 am I have a terrible time taking a poop." My other friend said -- "At 8:00 am my problem is taking a piss." I replied -- "At 8:00 am I crap like a goose and piss like a race hoarse." Both friends said: "That doesn't sound bad -- what's the problem?" I told them "Yeah, but I wake up at 9:00 am." Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open form in new window
On Mar 4, 2013, at 3:17 PM, Paul M Foster wrote: > On Mon, Mar 04, 2013 at 05:39:00PM +, Tim Streater wrote: > >> On 04 Mar 2013 at 17:10, John Taylor-Johnston >> wrote: >> >>> Submit will not >>> submit the form contents. >> >> Nothing to stop your OpenWindow() function doing a submit as in: >> >> Submit >> >> >> function OpenWindow (formPtr) >> { >> >> // Some actions >> >> formPtr.submit (); >> >> } >> >> > >> Personally I never submit forms. I use ajax to communicate with PHP >> scripts and do something with the data that is returned by the script. >> You can see a simple example at http://www.clothears.org.uk > > -- >> Cheers -- Tim >> > > I'm trying to figure out where the net gain in that is. The PHP file > being called via AJAX is doing its processing on the server either way. > So it appears the only difference is an asynchronous Javascript/AJAX > call or a synchronous PHP call (on a standard PHP form submission). What > am I missing? > > Paul > Yes, I agree with Paul -- how about an example? That way we can see what you are trying to do. You see, I use ajax all the time to send all sorts of things to the server without refresh, but I am at a lost to figure out what you are doing. Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web Developer Opportunity
On Mar 4, 2013, at 3:10 PM, Allison Garcia wrote: > *SMALL WORLD LABS is looking for a PHP WEB DEVELOPER * > > Small World Labs is looking for a PHP Web Developer to be a part of our > team. The position is focused on managing, supporting and expanding the > Small World Labs social collaboration and online community platform. This > role will interface with the product, support, professional services and > client teams to provide technical guidance and drive future platform > expansion. You will be responsible for both front & back-end development > for the Small World Labs platform. > > We are looking for an intelligent, fast learner who can thrive in a high > energy environment. Strong knowledge of PHP and the ability to work in a > dynamic team are required. > > *Technical Background:* > - PHP (the primary development language) > - CSS, MYSQL, DHTML, Javascript, JQuery, AJAX > - Web Services using SOAP or RESTful API > - Mobile development > - Understanding of version control systems > - Familiarity with Linux or another UNIX OS is preferred > > *Required Experience:* > - At least 3 years successful technical development experience > - Proven ability to manage multiple projects in a fast paced environment > - Ability to take ownership over development projects > - Knowledge of online social and professional networks and developer > interfaces > - Strong communication skills, both written and verbal > - Experience with requirements gathering > > *Education:* > - Bachelors or graduate degree > > *Location:* > - Austin, Texas > > Interested parties, please email your resume with the subject line "PHP Web > Developer" to j...@smallworldlabs.com. > > *About Small World Labs* > Small World Labs is an experienced provider of an online community and > social collaboration platform that enables organizations to connect with > their constituents in new ways. We help non-profit organizations understand > how to engage with their members to drive loyalty, create opportunities, > ignite conversations, distribute knowledge, and share experiences. What are you offering? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open form in new window
On Mar 4, 2013, at 12:54 PM, John Taylor-Johnston wrote: > If you want to open a new page in response to a submit button press (using > PHP) you may be out of luck. I don't know of a way to do it without involving > another language. Opening a different page in the *same* window, yes. > Otherwise, no. But watch the other replies. Maybe someone knows something I > don't. Paul > Nope. Out of luck. You mean opening a new page while keeping the current page open? Because clicking a form submit *can* open a new page as per the form's action="" attribute. If you want the current page to remain open while another page opens, then you'll need a javascript routine to do it. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web Developer Opportunity
On Mar 5, 2013, at 7:18 PM, Matijn Woudt wrote: On Wed, Mar 6, 2013 at 1:16 AM, Tedd Sperling wrote: > On Mar 4, 2013, at 3:10 PM, Allison Garcia wrote: > -snip- > What are you offering? > > $2/hr. > > Oh, It's not Friday.. Is it more on Friday? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open form in new window
On Mar 5, 2013, at 10:12 PM, Jim Giner wrote > On 3/5/2013 7:32 PM, Tedd Sperling wrote: >> On Mar 4, 2013, at 12:54 PM, John Taylor-Johnston >> wrote: >> >>> If you want to open a new page in response to a submit button press (using >>> PHP) you may be out of luck. I don't know of a way to do it without >>> involving another language. Opening a different page in the *same* window, >>> yes. Otherwise, no. But watch the other replies. Maybe someone knows >>> something I don't. Paul >>> Nope. Out of luck. >> >> You mean opening a new page while keeping the current page open? >> >> Because clicking a form submit *can* open a new page as per the form's >> action="" attribute. >> >> If you want the current page to remain open while another page opens, then >> you'll need a javascript routine to do it. >> >> Cheers, >> >> tedd >> >> _ >> t...@sperling.com >> http://sperling.com >> >> > No - you meant to say "per the form's TARGET attribute" No, I meant to say exactly what I said, namely ACTION. The Target attribute deals with frames -- I have not done frames since 1995. For a more in-depth Target explanation, please review: http://www.htmlcodetutorial.com/forms/_FORM_TARGET.html However, I do not think that is what is being discussed here -- at least it is not what I was talking about. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing
On Mar 8, 2013, at 1:20 PM, Dustin L wrote: > This is my first time using a list. Can anyone confirm I'm doing this > correctly? > > > Thanks, > > > Dustin L. Oh, now you did it! There will be dogs and cats in the streets. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] webform spam prevention
On Apr 4, 2013, at 5:02 AM, Ashley Sheridan wrote: > or you can't see at all) then you have to fall back to the audio > replacement offered by the captcha. I've tried listening to some, and > they are awful. > > > Thanks, > Ash Ash: How about the second one down? Can you hear this one clear enough? I like the circle one. I can place the circle anywhere on the page and ask the user to click it, but you have to be able to see it. The third one is simple enough. The forth one is bot proof, but a bit difficult for some to figure out and for the blind to see. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Apr 19, 2013, at 4:43 PM, Glob Design Info wrote: > I know this has probably been answered already. > > When I pass a user name and password from a form to my PHP script and then > pass those to mysql_connect it doesn't connect. When I paste those exact same > values into mysql_connect as string literals it works. > > Can anyone tell me why this happens? > > I know the strings are identical to the literals I try in a test but they > don't work when submitted via form. > > $form_user = $_POST[ 'user' ]; > $form_pass = $_POST[ 'password' ]; > > # Connect to remote DB > > $LINK = mysql_connect( $host, $form_user, $form_pass ); > > And yes, my $host param is correct. > > Thanks, Why are you allowing anyone to connect to your database from a form? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Apr 20, 2013, at 11:44 AM, Stuart Dallas wrote: > On 20 Apr 2013, at 16:25, Jim Giner wrote: > >>> Why are you allowing anyone to connect to your database from a form? >>> >> A little OT, but... >> What do you mean by this question? How do you check someone's credentials >> if not by connecting to a db to verify the login? Cause I'm doing the same >> kind of thing all over the place. With good practices on validation and >> such before doing my query of course. > > I'm pretty sure that's not what tedd meant. The code is logging in to the > database server using the username and password from the form. There are very > few legitimate reasons to be doing this, so the question is well worth asking. > > -Stuart Stuart is exactly right. If you are checking someone's credentials to access your site, such as a user, then giving them the "keys to the kingdom" is a bit of an overkill. My advice, set up "user_id" and "password" fields in a "user" table for users you want to access some portion of your site, here's the code to do that: http://sperling.com/php/authorization/log-on.php Where I have said "// define your user id here" is the place to actually open your database and access your user table to gather the correct user_id and password. I also suggest that when you open the database you only use literals from a config.php file ($dbhost,$dbuser,$dbpass) for accessing the actual database and then check the user_id and password before giving them authorization to private areas. Keep the private stuff private! Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Apr 21, 2013, at 9:32 AM, Stuart Dallas wrote: > However, a more important question for me is why you are doing this. You say > you are aware of the security implications, and that you'll "deal with that > later," but I question how you're going to deal with it. What exactly are you > developing that requires DB credentials to come from a form on a web page? > > -Stuart You and I are asking the same question, but I am afraid the poster is not listening. Instead, he is pursuing a course of action that simply repeats his problem. His focus is on a specific tree instead of the forest. He doesn't want to widen his view. Until the poster answers our question, I'm afraid our recommendations will fall on deaf ears. Some days you can help and some days you can't. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect noob question
On Apr 21, 2013, at 3:33 PM, Glob Design Info wrote: > What question did I not answer? That proves that you're not listening -- you are total waste of time for anyone trying to help. Welcome to my ignore file. tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generate onfly PDF
On May 4, 2013, at 5:00 PM, Ashley Sheridan wrote: > Rafnews wrote: > Is there a solution to generate onfly PDF from HTML page, and from data >> >> user typed in form (let's say like a template) without using PECL ? >> i read that is hosting does not allow such extension, we can not >> generate PDF, so i would rather get a solution without such library. >> >> Moreover i'm searching a solution free and that i can supply with my >> web >> components. >> I created a component that should be able to generate PDF files quite >> often as service for user. > > Have a look at fpdf, its a class that doesn't need any special server-side > support. Its basic, but is pretty good. > > Thanks, > Ash Ash is right, here's an example I provide my students: http://rebel.lcc.edu/sperlt/citw185/examples/pdf/ Everything is there. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On May 8, 2013, at 12:50 PM, Daniel Brown wrote: >If you're going to send hack attempts, at least adjust your clock > so that it doesn't look like it took almost a month for your SPAM to > get here. We're not the Pony Express. (And, no, PHP doesn't stand > for Produced by Horses & Ponies.) > > On Thu, Apr 11, 2013 at 11:43 AM, Paul Novitski > wrote: >> http://www.shinwa-kensetsu.sakura.ne.jp/bth7rz.php I'm not sure what's going on with Paul's account -- he doesn't "normally" do stuff like that. I even bought his book. Cheers, tedd PS: PHP + > "Produced by Horses & Ponies." ? You got too much time on your hands Daniel. As for me, I just wasted 20+ hours on a clueless client. It would be nice if people kept their word. _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
-Dan: I teach this stuff and still don't fully understand the why/when for interfaces. Even the guru's I talk with can't give me a good explanation as to what the advantages are in using them. I've done a lot of experimenting and can't see any advantage for them other than grouping different classes together and creating a new data-tytpe. Other than that, from my perspective interfaces are mythicode. So, if you find a good reference, please let me know. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com On May 16, 2013, at 11:11 AM, Dan Joseph wrote: > Thanks! This looks like a good start. Covers some things I have questions > on. I like his approach. > > Now I just need something advanced to continue on after this. I'd like to > learn more about extending, interfaces, abstracts, and why/when they should > be used. > > Appreciate it! > > -Dan > > > On Thu, May 16, 2013 at 11:01 AM, Francisco C Soares > wrote: > >> On 05/16/2013 11:55 AM, Dan Joseph wrote: >> >> Hey Folks, >> >> I'm looking to refine my PHP 5 OOP skills. I know the basics, understand >> patterns, but have clearly missed a few things along the way. >> >> Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked you >> could share? Something other than php.net/oop5. >> >> Try, >> Tente, >> >> http://www.killerphp.com/tutorials/object-oriented-php/ >> >> Success! >> Sucesso! >> >> ___ >> Francisco C Soares ( *Junior* ) >> 403790c89847cdbe5a262146de8fb93139c4 >> >> BLOG dotjunior.blogspot.com >> > > > > -- > -Dan Joseph > > http://www.danjoseph.me > http://www.dansrollingbbq.com > http://www.youtube.com/DansRollingBBQ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
Thanks to both Bastien and Sebastian: While I understand that an interface is like an abstract Class, in that you don't have to flesh-out your methods, but rather where you define exactly how Classes who implement that interface will be required to flesh-out those methods. But so what? What's the point? Without giving me complicated examples, just give me one simple example that illustrates the advantage of using an interface over writing a new Class where you flesh-out whatever methods you want. After all, an interface requires the same thing, does it not? As such, I just don't see the advantage interfaces bring. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
Nick: I thank you for your addition, but what you provided did nothing to explain the difference between abstract and interface. In your example: An abstract Shape with Circle and Square inheriting. OR An interface Shape with Circle and Square implementing. Does exactly the same thing -- so where's the difference? Also, your: Please make an effort to understand polymorphic concepts of OOP as they are rudimentary. Without that one will never grasp OO Patterns (Gang of Four). Was more insulting than helpful. Polymorphism was not the question asked. Clearly the getArea() method is polymorphic and overridden in both Circle and Shape classes and also in BOTH abstract and interface examples. Additionally, I'm not sure what: > (int double side) means. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com - On May 16, 2013, at 8:47 PM, Nick Khamis wrote: > interface Shape { > public double getArea(); > } > > class Circle implements Shape { > double radius; > public Circle(int double radius) { >this.radius = radius; > } > > public double getArea() { >return (radius * radius * 3.1415); > } > > } > > class Square implements Shape { > double side; > > public Square(int double side) { >this.side = side; > } > > double getArea() { >return (side * side); > } > } > > > Please make an effort to understand polymorphic concepts of OOP as > they are rudimentary. Without that one will never grasp OO Patterns > (Gang of Four). > > Ninus. > > On 5/16/13, Tedd Sperling wrote: >> Thanks to both Bastien and Sebastian: >> >> While I understand that an interface is like an abstract Class, in that you >> don't have to flesh-out your methods, but rather where you define exactly >> how Classes who implement that interface will be required to flesh-out those >> methods. But so what? What's the point? >> >> Without giving me complicated examples, just give me one simple example that >> illustrates the advantage of using an interface over writing a new Class >> where you flesh-out whatever methods you want. After all, an interface >> requires the same thing, does it not? >> >> As such, I just don't see the advantage interfaces bring. >> >> Cheers, >> >> tedd >> >> >> _ >> tedd.sperl...@gmail.com >> http://sperling.com >> >> >> >> -- >> 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] A Good OOP Tutorial/Read?
Stuart: You said: > An interface does what it says on the tin: it describes an interface that a > class can then tell the world it implements. > > An abstract class provides functionality as well as an interface description. > An abstract class cannot be instantiated, it can only be extended. > > The logging example given by someone earlier in this thread is the most > common example given for interfaces. This is where the interface is defined > as an API for others to implement and/or use which then enables users to pick > and choose the combination of implementations they want to use based on their > requirements without needing to change any of the code of either class. I understand the "stated" differences between abstract and interface. I can cite what the differences are, but I don't see the practical application differences. To me there is no difference between an abstract class (without method declarations) and an interface. However, I view an interface as a statement (a contract) where IF you want someone to use your code you outline the methods you require them to flesh-out in their code -- but I would like to see a simple example of that. I vaguely get the logging example given by Larry, but I'm not good at abstract thinking -- I need a concrete simple example. I tried to create a demo where I had a Toaster Class that contained breadNumber() and toastSetting() methods and then created an interface so my students could use the Toaster, but it didn't really hold up as well as I wanted. So, can anyone give me a simple example where an interface is used so I can easily explain why they are important? Thanks, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
On May 19, 2013, at 5:19 AM, mrfroasty wrote: > On 05/16/2013 11:28 PM, Tedd Sperling wrote: >> So, if you find a good reference, please let me know. > > In my point of view, Interfaces and Abstracts are completely different stuffs > not related at all.Interface is a kind of a way of defining how all objects > should behave or written by developers (one has used a word contract or > agreement). > > For instance we are writting this huge application where hundreds of > developers are going to work together.We make an agreement all objects in > this application should provide a function for someone debug to see all the > contents or data in that object and call this method $this->debug(); > > In order to guarantee that developers will have to obey this agreement, the > only way is to throw some bunch of exception when they do not.This can be > defined in an interface.Where everyone implimenting this interface (creating > objects) must have a function called debug(). I understand all of that -- but that's not the question I am asking. Certainly, I can create an interface and if anyone wants to implement the interface, then they are forced to flesh-out the methods it contains. I understand that -- it's a contract. But the other side of the argument is why would anyone want to do that other than to meet a design criteria? It is very easy to understand double inheritance -- it is simply where a child can inherit methods from both parents. But in languages that do not support double inheritance, an Interface is offered as a solution -- and therein is my question. So, in that regard how does an Interface provide methods to classes that implement the Interface? Just show me a *simple* example (either php or Java will do). Cheers, tedd PS: There have been people who have provided Interface examples, but none have demonstrated quasi-double inheritance. _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Good OOP Tutorial/Read?
To all: Thanks to Stuart, I finally got it. The concept of Interface is a bit difficult to explain, but his excellent console made the concept clear. Many thanks to all for their efforts to educate me. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php