Re: [PHP] Re: array_map() with multiple callback functions
On 2013-05-08, at 1:48 PM, Jim Giner wrote: On 5/7/2013 5:29 PM, George Langley wrote: Hi all. I want to apply strtolower() AND trim() to all items in an array. But I don't see a way to call multiple callbacks with the array_map() function. Are my two choices the following: // 1) nesting two array_map() calls $cleanData = array_map('trim',(array_map('strtolower',$rawData))); // 2) call my own function with array_walk() $cleanData = array_walk('myCleaner',$rawData); function myCleaner($passedData){ $cleanData = array_map('strtolower',$passedData); $cleanData = array_map('trim',$cleanData); } //(Of course, wouldn't bother with a function, just to call array_map twice...) Just seeing if there's a better way than having to go through the array twice to apply each callback separately. Thanks, Not sure if you have an answer to this yet, so I'll present my simpler approach. foreach ($my_array as $v) { $v = trim($v); $v = strtolower($v); } -- On 2013-05-07, at 3:43 PM, Alex Nikitin wrote: Something like: $cleanData = array_map(function($str){return strtolower(trim($str));}, $passedData); -- Thanks guys - will check both out to see what works best in my situation. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_map() with multiple callback functions
Hi all. I want to apply strtolower() AND trim() to all items in an array. But I don't see a way to call multiple callbacks with the array_map() function. Are my two choices the following: // 1) nesting two array_map() calls $cleanData = array_map('trim',(array_map('strtolower',$rawData))); // 2) call my own function with array_walk() $cleanData = array_walk('myCleaner',$rawData); function myCleaner($passedData){ $cleanData = array_map('strtolower',$passedData); $cleanData = array_map('trim',$cleanData); } //(Of course, wouldn't bother with a function, just to call array_map twice...) Just seeing if there's a better way than having to go through the array twice to apply each callback separately. Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Affordable low-fee e-commerce - DIY?
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 www.georgelangley.ca
Re: [PHP] Sniping on the List
It's another nail in the coffin of deity constructors. - And just as this thread was getting boringly OT! ;-{)] George Langley Interactive Developer www.georgelangley.ca
[PHP] Sniping on the List
Am concerned over the number of posts that appear to be from people trying to over-inflate their self-importance. If you are the world's best coder, then help those of us who aren't. If you happen to know a better way to do something that I'm struggling with, then please share it. But if you just want to take pot shots at us, then please keep your comments to yourself. To that end, I wish to thank Ashley Sheridan, Daniel P. Brown, Tedd Sperling and Tommy Pham, to name but just a few of those who have submitted incredibly-helpful posts, that I have kept for reference. Your contributions are very much appreciated - thanks. George Langley Interactive Developer www.georgelangley.ca
Re: [PHP] Frivolous Friday Fun!
On 2011-11-11, at 11:08 AM, Jason Pruim wrote: And on a serious note... To any Past, Present, Or Future service man (Or woman) Thank you for your sacrifice in defending our ability to send out these Frivolous Friday emails! :) You're welcome! CPO2 George Langley HMCS TECUMSEH Naval Reserve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] BP for Looping through an Array
Hi all. Am wondering if there is a best practice for looping through an array, when you need both the item and its position (ie. 1, 2, 3). The two ways I know of: // the for loop tracks the position and you get each item from the array $allFiles = array(coffee.jpg, tea.jpg, milk.jpg); $numberOfFiles = count($allFiles); for ($i=1; $i=$numberOfFiles; $i++) { $currFile = $allFiles[$i - 1]; // since arrays start with 0 doThisWith($currFile); doThatWith($i); } OR: // the for loop gets each item and you track the position $allFiles = array(coffee.jpg, tea.jpg, milk.jpg); $counter = 1; foreach ($allFiles as $currFile) { doThisWith($currFile); doThatWith($counter); $counter += 1; } Both are the same number of lines, but my tests (see code below) indicate that the foreach loop is twice as fast. Anyone have a better way - faster, more efficient, cooler, etc.? (Or see some flaw in my test code below?) Thanks. George Langley -- TEST CODE -- ?php echo h1Loop Test/h1; // create a large array $theArray = array(); for ($i=1; $i=100; $i++) { array_push($theArray, $i); } $confirmCount = count($theArray); echo h2An array of $confirmCount items (numbers 1 to $confirmCount) has been created./h2; echo tabletrtdbType of Loop/b/tdtdbTime Taken to Add Up/b/tdtdbaddUp Value/b/td/tr; for ($x=1; $x=10; $x++) { // run tests 10x // the for loop tracks the position and you get each item from the array $addUp = 0; $time_start = microtime(true); $numberOfItems = count($theArray); for ($i=1; $i=$numberOfItems; $i++) { $currItem = $theArray[$i - 1]; // since arrays start with 0 $addUp += $currItem; // give it something to do } $time_end = microtime(true); $time = $time_end - $time_start; echo trtdFor (Tracks Position): /tdtd$time/tdtd$addUp/td/tr; // the for loop gets each item and you track the position $addUp = 0; $time_start = microtime(true); $counter = 1; foreach ($theArray as $currItem) { $addUp += $currItem; // give it something to do $counter += 1; } $time_end = microtime(true); $time = $time_end - $time_start; echo trtdForeach (Tracks Items): /tdtd$time/tdtd$addUp/td/tr; echo trtdnbsp;/tdtdnbsp;/tdtdnbsp;/td/tr; } echo /table; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] different menus for different roles
On 2011-10-20, at 12:31 AM, drupal dev wrote: I have created two domains in drupal. and two different roles. Now i wanted to show different page for each role.can you anybody tell me how to do it. Or share with me if something is readily available. Um, drupal.org would fall into that latter category: http://drupal.org/project/menu_per_role Remember: Google IS your friend. G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with code...
On 2011-10-06, at 6:28 PM, Jason Pruim wrote: ?PHP //SETUP VARIABLES $mailTo = li...@pruimphotography.com; $mailFrom = li...@pruimphotography.com; //These 2 can be changed IF you know what you are doing and why! $returnPath = $mailFrom; $replyTo = $mailFrom; $mailSubject = New Convention registration!; $message = ; //DO NOT CHANGE UNDER PENALITY OF BEING SLAPPED WITH A WET NOODLE!!! $headers = From: .$mailFrom.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; function send_email($mailTo, $mailSubject, $mailMessage, $headers) { if(mail( $mailTo, $mailSubject, $mailMessage, $headers )) { $message = Thank you for registering!; }else { echo There was an issue with your registration.. Please try again later; } }//Close Function if(!empty($errorCount)) { }else { //Build Email message $mailmessage = Full Name: . $_POST['firstname'] . . $_POST['lastname'] . \n\n; $mailmessage .= Address: . $_POST['address'] . \n\n; $mailmessage .= City, State, Zip: . $_POST['city'] . . $_POST['state'] . . $_POST['zip'] . \n\n; $mailmessage .= Phone: . $_POST['phone'] . \n\n; $mailmessage .= Email address: . $_POST['email'] . \n\n; if($_POST['affiliation'] == NFBOther) { $mailmessage .= Chapter Affiliation: . $_POST['other'] . \n\n; }else{ $mailmessage .= Chapter Affiliation: . $_POST['affiliation'] . \n\n; } if($_POST['person'] ==Other){ $mailmessage .= Who will pick up the ticket? . $_POST['Pfirstname'] . . $_POST['Llastname'] . \n\n; }else{ $mailmessage .= Who will pick up the ticket? I will pick it up my self! \n\n; } $mailmessage .= Payment Method: . $_POST['paymentMethod']; send_email($mailTo, $mailSubject, $mailmessage, $headers); } ? Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Anyone have any ideas? I'm stumped Hi there. First thought is perhaps it is not getting a value for paymentMethod and if it doesn't exist, will the line still get added? I would always check to see if every post variable isset, before adding the line. Can write a default line in its place if missing. George Langley Interactive Developer RIP, Mr. Jobs.
Re: [PHP] book quest
On 2011-09-29, at 8:53 AM, Andy McKenzie wrote: Is there something wrong with the PHP.net manual? Or you just want something physical to be able read any where and stay unplugged? If the latter and there's nothing wrong with the official manual, try downloading the chm or single html file and print as you go. No need to lug around thick that manual/reference ;) Regards, Tommy I didn't find that there was anything wrong with the PHP.net manual, except that it wasn't a book about learning to program. It's a fantastic reference guide; if I can't remember what order the inputs to that one function go in, it's my first resort. But I prefer to read paper for learning theory, and I find it more useful to flip through pages trying to find something I half remember than to click through links. Put simply, I like to learn the basics from books rather than web pages. -- And as the OP said, something that they can carry around - websites don't always cut it on the morning commute! (Although I hope the OP wouldn't smoke anything!) I too prefer books, as they are usually organized as a training course, starting you with the basics and walking you through a logical progression of learning, as well as giving real-world lessons and experience. Not saying that php.net is or isn't, but more often than not, the manuals that come with software are organized by sections or features, and do not give you the basics from which to start. It's no good to start with This is the drawing tool, if you don't know how to create a canvas to draw on. Reference books/sites are good once you know the basics on proper techniques, best practices and sensible workflows, and you can now expand into the full features that the software can offer. Plus, they can target your skills and desired learning - am currently researching Drupal, and have found some books that teach the basics on using it within its limits, and then others that teach how to build your own modules and plugins. Depending on what you are looking for, you can quickly target the skills you need to learn. And, is easier to make your notes in the margins on a piece of paper! Having said that, one of the main books I used for PHP was Apress' Beginning PHP and MySQL, which is now in a 4th edition: http://www.apress.com/9781430231141 It provided a logical approach to both technologies and how to integrate them, all in one book. Then get one that focuses on security. O'Reilly has one (or more), but the one I picked up was Securing PHP Web Applications: http://www.amazon.ca/Securing-PHP-Applications-Tricia-Ballad/dp/0321534344 and was a good read. I just wish book publishers offered an upgrade path if you bought an earlier edition, the way software publishers do! Perhaps that will be the greatest advantage an iPad or Kobo will have over paper. George Langley Multimedia Developer
Re: [PHP] Any free online tests to test my PHP knowledge?
On 2011-09-22, at 11:53 AM, Mike Hansen wrote: Does anyone know of a site that has an online test of PHP skills? I'd like to review my PHP knowledge. I've already run across this site: http://vladalexa.com/scripts/php/test/test_php_skill.html Doesn't appear to be working. Just has a link to some blog and no results. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] While on the topic of PHP Web Site Stats - SharePoint...
Hi all. Had a meeting today where I was rather condescendingly told that most CMS web sites use SharePoint. Last I checked: http://trends.builtwith.com/cms Wordpress, Joomla! and Drupal (PHP, PHP and oh look, PHP) kind of had the CMS market wrapped up, with numerous other systems fighting for the remains. In fact, I don't see SharePoint even listed at the above link. Any stats on (warning - buzzwords ahead) External-facing web sites using SharePoint? At $$$ for the required server software, compared to $ for just about anything PHP-based, can only imagine companies using SharePoint must have their IT department in charge of the web site. Am sure it's fine as an internal project management tool, but am very concerned when other developers tell me to run away from anyone who chooses to use SharePoint on anything public. Thanks. George Langley Interactive Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Repetitive answers . . .
On 2011-09-09, at 11:34 AM, Marc Guay wrote: That low-hanging fruit is too hard for some to resist... --- Phishing is a art. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Repetitive answers . . .
On 2011-09-09, at 12:39 PM, Larry Martell wrote: On Fri, Sep 9, 2011 at 12:36 PM, Daniel Brown danbr...@php.net wrote: On Fri, Sep 9, 2011 at 14:30, Robert Cummings rob...@interjinn.com wrote: Oblig: http://www.youtube.com/watch?v=sUntx0pe_qI I didn't know it was possible to fill almost four minutes with a single note, outside of a test pattern. That's got to be the worst singer I've ever heard in my entire life. I agree, I only lasted 1 minute. Oh, so you didn't see the (as my kids like to say) totally random 30-something-year-old male rapper suddenly appearing in a 14-year-old girl's video about partying like she's an adult? Something very wrong with a who that pays to get her daughter into a video like that... But thanks for reminding me that it is Friday. They all blend together when you're between jobs... And now, back to the job search George Langley Interactive Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 2011-08-31, at 11:44 PM, Ross McKay wrote: On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But style is really up to the individual -- what works best for you is the best (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with KR :) --- FWIW, am working my way through an O'Reilly book (HTML5 Canvas) right now and they appear to use The One True Brace Style in their code examples. Not religious about it, but it does help me know which code I wrote and what was touched by someone else! George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Code should be selv-maintaining!
The One True Brace Style: http://en.wikipedia.org/wiki/Indent_style Didn't know there was a name for the way I learned to indent! Make sense to me - looks so much cleaner and less scrolling/printing. And, I already add a comment to confirm the end brace: } // end if($myVar) to clarify any long nests. George On 2011-08-29, at 2:05 PM, Richard Riley wrote: Robert Cummings rob...@interjinn.com writes: On 11-08-29 03:42 PM, Rico Secada wrote: You go into your homemade library of code to re-use some piece that you already are using 12 other places in production. Now, last time you worked on the code you thought it was almost perfect. While working on the code this time you find an undiscovered bug or some part of the code that looks like you where on drugs when you made it. More an issue with library management :) git checkout releaseV1.1 ; *lol* Yes, I think we've all seen it from time to time. Have you ever gone back and looked at your school assignments in coding? *shudder*. The horror is compounded by the fact I was using KR style indentation back then ;) small point of order : KR indentation is still considered by many as the cleanest and is used on many many large code bases. Personally I much prefer f(){ a; } to f() { } as the first one is two boundary balanced. But like emacs vs vi it's a religious issue -- 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] Fwd: ezmlm warning
On 2011-07-20, at 5:40 AM, Jan Reiter wrote: Hi, I'm in Germany and I got it, too. I get those about once in 6 month ... nothing to worry about, is it?? Regards Got it here: Canada with Shaw ISP. But am getting this thread now, so assume it's fixed? George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Report generation as pdf and csv in php application for huge record set
On 2011-07-14, at 12:50 AM, Midhun Girish wrote: On Thu, Jul 14, 2011 at 11:18 AM, George Langley george.lang...@shaw.ca wrote: On 2011-07-13, at 11:20 PM, Midhun Girish wrote: Hi, - Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and reach the limit, it will be lost. It is therefore advised for very big documents to generate them in a file, and to send some data to the browser from time to time (with a call to flush() to force the output). When the document is finished, you can send a redirection to it or create a link. Remark: even if the browser times out, the script may continue to run on the server. When it comes to the user end, they wont wait for more than 1 min. So redirection after generating the report is not possible. But creating link may be a good idea. How can it be done? I mean shouldn't there be a service running in the server to process these request after the execution of the php script is completed? Also shouldn't we post all the report generation request to a database so that serial processing can be done? --- We're helping each other here, as I'm facing a similar situation! Read up on how to store as a file here: http://www.sitepoint.com/generate-pdfs-php/ You should then be able to generate an email notification to send once the file is complete, with the link to the newly-created file. George Langley Multimedia Developer Suppose we are using this tool at sever side. We have set up the php page so that all request will be saved in a db. And based on the conditions in request a pdf CAN be generated by this tool. My question is how will we give the trigger for generating this pdf? We cant do it in the php script due to the timeout problem. The only solution i can think of is a cron which is repeated every 5 min or so which fetches records from the db and generates the pdf. But even with a cron we will face the timeout problem. Is there any alternative to a cron like a server side service or something? Midhun Girish -- As I understand it, the server-side timeout can be increased in the php.ini setting. So the PHP script can run as long as required if that is set sufficiently high enough. As long as you send something to the browser to confirm that the process has started, the browser-side timeout will not be a problem and your user will know to wait until notified by email that the file is ready. Once the script has completed, it stores the final db record and sends the email. George
Re: [PHP] Your language sucks because...
On 2011-07-14, at 4:36 AM, Ashley Sheridan wrote: That's a massive pet hate of mine, along with using here/hear in the wrong way and those who have no idea of the difference between there, their they're. Makes me want to beat them upside the head with a dictionary :) Mine are it's and its (Remember: it's its!), people who say people that (It should be People WHO!) and the complete lack of regard to plural versus singular verbs (There's lots? No, there ARE lots of examples of that out there!). As far as the original list: http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because: it's just a tongue-in-cheek way to point out inconsistencies in the various languages. However, is kind of out-dated, referring to PHP 4 and CSS 2, so am wondering how many of the entries have been rectified? (For instance, CSS 3 does have multiple background images.) As well, I suspect that some of them may actually make sense if analyzed as to why they are that way, instead of how the author has grouped them. George Langley Multimedia Developer
Re: Re: [PHP] Your language sucks because...
- Original Message - From: Micky Hulse rgmi...@gmail.com On Thu, Jul 14, 2011 at 4:02 AM, Richard Quadling rquadl...@gmail.com wrote: My daughter (6 or 7 at the time) came up with T, M and E. I was abso-bloody-lutely amazed she managed to find a word starting with T, M and E. What was the word? -- He gave you a beautiful hint: tmesis |təˈmēsis| noun ( pl. -ses |-sēz|) the separation of parts of a compound word by an intervening word or words, heard mainly in informal speech (e.g., a whole nother story; shove it back any-old-where in the pile). ORIGIN mid 16th cent.: from Greek tmēsis ‘cutting,’ from temnein ‘to cut.’ George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Report generation as pdf and csv in php application for huge record set
On 2011-07-13, at 9:59 PM, Midhun Girish wrote: I have an erp application developed in php (zend framework actually). There are many reports which the admin level users can take from the application. Some reports have more than 600,000 records. The viewing of reports in the browser is fine as i have paginated the result. But when it comes to exporting the entire report as pdf and in excel format, im in trouble. I use fpdf for pdf generation and a custom class for converting result to excel. Both these fails when the number of records exceeds 500. Now i have pagianted the report generation and users can download the pdf page wise. But that is not the exact requirement. Im in need of a tool to generate pdf and excel(or csv) for large data set. I came across http://www.htmldoc.org/when i googled for one. Has anyone in the list has faced a similar problem. How exactly is report generation possible when the number of records is extremely huge? Is there a good solution which can be implemented in php? Please help. - Hi there. FAQ #16 on: http://www.fpdf.org/en/FAQ.php#q16 has some useful info on handling large files: 16. What's the limit of the file sizes I can generate with FPDF? There is no particular limit. There are some constraints, however: - The maximum memory size allocated to PHP scripts is usually 8MB. For very big documents, especially with images, this limit may be reached (the file being built into memory). The parameter is configured in the php.ini file. - The maximum execution time allocated defaults to 30 seconds. This limit can of course be easily reached. It is configured in php.ini and may be altered dynamically with set_time_limit(). - Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and reach the limit, it will be lost. It is therefore advised for very big documents to generate them in a file, and to send some data to the browser from time to time (with a call to flush() to force the output). When the document is finished, you can send a redirection to it or create a link. Remark: even if the browser times out, the script may continue to run on the server. HTH George Langley Multimedia Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Report generation as pdf and csv in php application for huge record set
On 2011-07-13, at 11:20 PM, Midhun Girish wrote: Hi, - Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and reach the limit, it will be lost. It is therefore advised for very big documents to generate them in a file, and to send some data to the browser from time to time (with a call to flush() to force the output). When the document is finished, you can send a redirection to it or create a link. Remark: even if the browser times out, the script may continue to run on the server. When it comes to the user end, they wont wait for more than 1 min. So redirection after generating the report is not possible. But creating link may be a good idea. How can it be done? I mean shouldn't there be a service running in the server to process these request after the execution of the php script is completed? Also shouldn't we post all the report generation request to a database so that serial processing can be done? --- We're helping each other here, as I'm facing a similar situation! Read up on how to store as a file here: http://www.sitepoint.com/generate-pdfs-php/ You should then be able to generate an email notification to send once the file is complete, with the link to the newly-created file. George Langley Multimedia Developer
[PHP] Self-whitelisting (WAS: Top Posting)
On 2011-07-05, at 8:52 PM, Jim Giner wrote: Huh? You have a problem with a person having a spam filter that requires one valid response to ensure that the mail from an address is from a real person ONE TIME ONLY? -- I know that I do. I monitor our web site's registration system, and will get a number of notices from things like Boxbe, stating that they've delayed the email with the confirmation link that we send our clients, until we confirm receipt of their notice. But, this can be used against you, as they now know that your address is valid, and can in turn spam you! Can read the ugly details on Wiki: http://en.wikipedia.org/wiki/Boxbe I won't subject my company to that nuisance. George Langley Multimedia Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Self-whitelisting (WAS: Top Posting)
On 2011-07-06, at 8:02 AM, Jim Giner wrote: George Langley george.lang...@shaw.ca wrote : On 2011-07-05, at 8:52 PM, Jim Giner wrote: Huh? You have a problem with a person having a spam filter that requires one valid response to ensure that the mail from an address is from a real person ONE TIME ONLY? -- I know that I do. I monitor our web site's registration system, and will get a number of notices from things like Boxbe, stating that they've delayed the email with the confirmation link that we send our clients, until we confirm receipt of their notice. But, this can be used against you, as they now know that your address is valid, and can in turn spam you! * But they can't spam me until they do make a response. And if they are actually in-human (!) enough to go to that length (and I suspect that the laziness factor of a spammer will reduce that possibility), I can easily blacklist them - which I have only had to do a couple of times in the last 5-6 years. Depends if they only require your response once for ALL of their customers. If they require it for each one, and you blacklist them, you won't receive the notices from any subsequent customers. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class not used as an object (Scope Resolution Operator)
Thanks all. Assuming is best then to add the static in this case. But it isn't required if I birthed an object first and referenced the object, correct? Am wanting to add some variables to the class so not calling the same query so many times... Thanks again. George On 2011-06-09, at 5:23 PM, David Harkness wrote: All of the above with a clarification: they are instance methods which you are calling statically. The object is not instantiated in this case. PHP allows this but will issue an E_STRICT warning. To remove the warning just add static before each of them, assuming they are only ever called statically: class myClass { static function doThis($passedVar) { doSomething; } static function doThat($anotherVar) { doSomethingElse; } } David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class not used as an object (Scope Resolution Operator)
Hi all. Am fixing some inherited code, and the previous coder created a class, ie: class myClass { function doThis($passedVar) { doSomething; } function doThat($anotherVar) { doSomethingElse; } } BUT, I don't see anywhere where he created an object, ie: $myObject = new myClass(); or $myObject = myClass::doThis(value); Instead, it's only ever just called directly with a Scope Resolution Operator, ie: myClass::doThis(valueOne); myClass::doThat($whatever); myClass::doThis(valueTwo); myClass::doThat($andSoOn); It seems that this would be making an object, and then destroying it again, on each of the four calls above, which I would think would be wasteful - time, memory, cpu usage, etc. The class has no constants or variables (properties) for any need for persistence, and is just a collection of functions (methods), so I don't see a reason to group them into a class - they could all reside as independent functions within the php file. Is this good? Is there some advantage to making a non-persistent class? Thanks! George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer
Re: [PHP] array_multisort into Natural order?
Hi there! Correct me if I'm wrong but merge() just makes one array of all items. array_multisort() keeps each array separate, while applying the same re-ordering to all three arrays. This allows you to use the same position number to get the required elements from each array, especially where each array is a list of different properties. For example: $name = array(Joe, Charlie, Jack); $age = array(30, 12, 66); $job = array(Plumber, Student, Retired); array_multisort($name, $age, $job); // will re-order all three arrays based on a regular alphanumeric sort of the names: // $name is now array(Charlie, Jack, Joe); // $age is now array(12, 66, 30); // $job is now array(Student, Retired, Plumber, ); // can now do: $firstName = $name[0]; // returns Charlie $firstAge = $age[0]; // returns Charlie's age 12 $firstJob = $job[0]; // returns Charlie's job Student A merge of these arrays will lose the different types of info each array currently has, and make it impossible to match a name to the age or job. Now, my other option is to group the items into a set of arrays: $array1 = array('name' = 'Joe', age = '30' job = 'Plumber'); $array2 = array('name' = 'Charlie', age = '12' job = 'Student'); $array3 = array('name' = 'Jack', age = '66' job = 'Retired'); $largeArray = array($array1, $array2, $array3); But, is there a way to the sort $largeArray, based on the name value in each individual array? And if so, can that use the natsort()? I don't think an asort() can do either. Note that the original source of this info is a mySQL db call, and it is initially sorted in the query, but again, there doesn't appear to be a way to natural sort an SQL query either. So I get file1, file10, file2, file20, file5 instead of file1, file2, file5, file10, file20 G - Original Message - From: Jim Lucas li...@cmsws.com Date: Monday, December 13, 2010 16:00 Subject: Re: [PHP] array_multisort into Natural order? To: George Langley george.lang...@shaw.ca Cc: php-general@lists.php.net On 12/13/2010 11:59 AM, George Langley wrote: Hi all. Can use natsort($array1) to sort a single array of filenames into a natural alphanumeric order - 1.php, 2.php, 5.php, 10.php, 20.php, etc. But using array_multisort($array1, $array2, $array3) doesn't offer a natsort option, so I end up with 1.php, 10.php, 2.php, 20.php, 5.php, etc. Anyone have a solution to this limitation already? Nothing found in the archives or Googling. Thanks. assuming that you are not using other options of array_multisort(), why not do something like this. $ar = array_merge($array1, $array2, $array3); natsort($ar); George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca
Re: [PHP] Brandon Rampersad wants to chat
Actually, it's been SEVEN times since 19 May, including today's. Perhaps the List Mom could step in here? George On 10-Jun-10, at 3:07 PM, Ashley Sheridan wrote: Please could you not send out these auto messages Brandon as I believe this is the second time a message has hit both my email address and the mailing list with a request for Google chat from you. Thanks, Ash http://www.ashleysheridan.co.uk On Thu, 2010-06-10 at 13:46 -0700, Brandon Rampersad wrote: --- Brandon Rampersad wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY You'll need to click this link to be able to chat with Brandon Rampersad. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with Brandon Rampersad, visit: http://mail.google.com/mail/a-b89a7a894d-87f44ca42c-QxVqdDj-Y-taKgwQ_V0g-Q8WRBY Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_GET is Mangling Base64 value
Hi all. Is there an issue with $_GET not handling a Base64-encoded value correctly? (PHP is 5.1.6) Am receiving a Base64-encoded value: theurl.com/index.php?message=x and retrieving it with $_GET: echo $_GET[message]; x is a Japanese phrase, that has been encoded into Base64. So is using the + symbol: ...OODq+OCou... but my $_GET is replacing the + with a space: ...OODq OCou... thus the base64_decode() is failing (displays diamonds with questions marks on my Mac). The Base64-encoded string is 156 characters long, if that has any bearing. My test URL is 230 characters in total, less than the old 256 limit. All I can find online is a reference that PHP will no longer assume that a space is a +: http://ca3.php.net/manual/en/function.base64-decode.php#69298 but my problem is the opposite - the + symbols are there, but the GET is removing them. (And to add a wrinkle, this then goes into a Joomla! page, whose getVar() command completely removes the +, so I couldn't even do a string replace, as I don't know where the + should have been!) Tired of looking at the dark red spot on the wall! Thanks. George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca
Re: [PHP] $_GET is Mangling Base64 value
Hi again. Thanks for all the info! Not sure I'd agree that GET should just assume it was URLencoded, but hey - who am I to argue? :-{)] As mentioned, this is eventually buried into a Joomla! site's login functions (displays any errors). So not sure I'd have access to the originating call to URLencode it before sending, if it's part of the standard Joomla! login function and not some of our custom code. However, Mike's suggestion to pre-parse it at our end: $_GET['foo'] = str_replace(' ', '+', $_GET['foo']); appears to work fine. I put the above in in just before the GET in my bare-bones PHP-only test, and in the actual Joomla! page just before their equivalent call: echo base64_decode(JRequest::getVar('message', '', 'method', 'base64')); Have tested it with strings that also included a / (being the other non-alphanumeric character that Base64 uses), and it remains unaffected. So, guess I can either add the pre-parse wherever I need to, or try to locate the call to see if I can urlencode it (and who am I to argue why they didn't do that too?!) Thanks again. George
Re: [PHP] ip-to-country
From my experience, I have had reported one incorrect country-level IP from Maxmind's paid service (returned US vrs Canada for a Canadian IP). But their free version is based on the commercial lists, just not updated as often, or automatically (you download and store locally on your server). So should be nearly as accurate as long as you maintain the lists (ie. think is weekly, being 2-weeks behind). That said, someone on another list is running a geo-location service comparison test, where you click links to the various services, then enter the location they returned. He was compiling the results, and so far has reported the following: -QUOTE--- So far some crazy numbers and realities. Of these numbers, all of the vendors missed 25 exact city locations equally. So our continued plan is to measure how far off the approx. 25% are so we can then say, OK, x vendor is 100% accurate up to x% and then x% accurate within say x-y miles. The shocking thing to us is still how some of the more expensive providers will say their definition of accuracy on a city level can be within 25 miles. Thus you would receive statistical confidence of a 90-100 for an IP that shows Pasadena, Calif. and yet in reality be located in Long Beach, Calif., or the same for San Jose, Ca. and yet be further up the peninsula in San Carlos, Ca. total: 103 ip2: 55 quova: 46 ipiligence: 32 whatis: 62 maxmind: 63 By the way, we are obviously way short still on queries so if you haven't clicked on the link, please do so and follow some ez pz instructions: http://www.stratosanalytics.com/iplookup.html -END QUOTE--- So help him out by clicking the link (although not sure what he means by e-zed-p-zed instructions ;-{)] ) George On 14-Dec-09, at 5:07 AM, Angelo Zanetti wrote: -Original Message- From: George Langley [mailto:george.lang...@shaw.ca] Sent: 19 October 2009 01:38 AM To: php-general@lists.php.net Subject: Re: [PHP] ip-to-country On 18-Oct-09, at 1:03 PM, SED wrote: How can I access an index for IP to a country (or a more detailed location)? http://www.maxmind.com/app/ip-location has both free and various paid services. George Hi George, How accurate are the free ones compared to the paid ones? Regards Angelo http://www.elemental.co.za http://www.wapit.co.za
Re: [PHP] sending email with php
http://articles.sitepoint.com/article/code-html-email-newsletters is a straight-ahead overview of what you can/should/cant/shouldn't do in HTML e-mails. Or check out: http://www.devshed.com/c/a/PHP/Composing-Messages-in-HTML-for-MIME-Email-with-PHP/ for some heavy-duty mail classes (be sure to check the See Also section for the full story). I also referenced the following: http://www.wilsonweb.com/wmt5/html-email-multi.htm on the basics of sending multi-part e-mail (ie. plain text AND HTML). HTH. George On 23-Dec-09, at 1:58 PM, Sudhakar wrote: ?php $headers = Content-type: text/html; charset=iso-8859-1; $to=myemailaddress; $subject=Email Newsletter; $message = '!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleEmail Newsletter/title meta http-equiv=Content-Type content=text/html; charset=utf-8 / meta name=robots content=noindex, nofollow / link rel=stylesheet type=text/css href=style.css / /head body div id=wrapper div id=topmenu /div div id=content div class=leftcolumn /div div class=rightcolumn /div /div div id=footer /div /div /body /html'; if(! mail($to, $subject, $message, $headers)){ echo There was an error is sending the email; } else{ echo The email has been sent; } ? hi my question is about send an email with php like a newsletter, when we read a newsletter email its similar to a webpage which contains content, images, css and other elements i created a static webpage initially with html css and images folder after creating the page i wanted to test to see how it would look if i were to send this as an email like a newsletter. so i have created a php file with $headers = Content-type: text/html; charset=iso-8859-1; $to=myemailaddress; $subject=Email Newsletter; and $message as mentioned above has the entire html code as i used it in my static html page i also copied the style.css in the server and created images folder and copied all the images i used in my static page to the server. i created a separate folder in my webserver called newsletter and copied the php file, css file and images folder with the images i used when i accessed the index.php as http://website.com/emailnewsletter i am getting a message that The email has been sent and i am getting the email however my question is when i open this email the styles and images are not being applied and i see only the text in the static page i created. can someone let me know how i can fix this so that when i open the email it would look like the static page i created with all the styles applies and images displayed is this only possible by using specialized email softwares or can it be done by php as well with the logic used. any help will be appreciated. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ip-to-country
On 18-Oct-09, at 1:03 PM, SED wrote: How can I access an index for IP to a country (or a more detailed location)? http://www.maxmind.com/app/ip-location has both free and various paid services. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP broadcast mailer
On 16-Oct-09, at 11:56 PM, George Langley wrote: At what point would it be beneficial to subscribe to a mass mail service such as Constant Contact or iContact, to avoid being blacklisted for sending too many e-mails? On 17-Oct-09, at 12:01 AM, Brian Hazelton wrote: I am sorry, but I am confused by your question. I thought that these companies worked with email providers to stay off the blacklists? --- They do - my point exactly. You may be fine for a small mass e-mail campaign (you mentioned 400 but growing). But if you do grow to the point of something getting triggered, and your URL or server, or worse, your ISP, gets black-listed, it may be hard to undo the damage. Am not sure what sort of limits any of these will allow before they start thinking you are spamming. Or how big you have to be to be considered trust-worthy to be allowed to send multiple e-mails. My main ISP (shaw.ca - 100s of 1,000s of customers) has gotten blacklisted a number of times, and suddenly friends would get e-mails to my @shaw address rejected, and had to start using one of my other addresses. A very tiny mail list I belonged to (40 people if even that) refused to send to all of its @shaw members, and I ended up re- registering under a different address because it happened enough times. The company I work for has internal clamps that get triggered if anyone tries to send to more than 50 addresses. They also run a separate mail server from their web site hosting. The site is hosted on Amazon's Cloud - a huge company, and yet every one of their IPs are black-listed: http://searchcloudcomputing.techtarget.com/news/article/0,289142,sid201_gci1371369,00.html The result was that even just a single e-mail to confirm registration to the member-only section of the site was getting flagged as spam by hotmail, or rejected outright by some other mail servers. Kinda hard to complete a registration if you never see the e- mail! We ended up relaying through our own mail server, which is fine for a one-at-a-time e-mail. But at over 50,000 customers, I have been strongly recommending the use of service if they do decide to start any mass e-mail newsletters or campaigns. Anyway, my point is - how important is this part of your business, and would it be worth the $ cost to use a service, rather than building, maintaining and potentially protecting your own? Just a thought. George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP broadcast mailer
Hi there. At what point would it be beneficial to subscribe to a mass mail service such as Constant Contact or iContact, to avoid being blacklisted for sending too many e-mails? George On 16-Oct-09, at 11:41 PM, Brian Hazelton wrote: I am in charge of an email newsletter list and making sure it gets sent out in time. My problem is I have never done broadcast emailing and right now we have 400 subscribers but want to build a system that can scale well regardless of the number of subscribers. Right now I use mysql to store the email and use phpmailer in a loop to send an email to each of the emails in the db, it is already slow with just 400(takes around 10 min (i think that's slow isnt it?). Has anyone built a broadcast email script and willing to help me? -- 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] Web Site Directory Layout
On 26-Sep-09, at 2:38 AM, Ashley Sheridan wrote: I tend to usually go with the following, using what fits with the project: index.php styles/ images/ scripts/ includes/ --- Add files/ for any download-able files. Then for multi-lingual projects, I'll add a content/[language]/ structure, to put my content php files in, while leaving the structural php files on the root. User preferences and cookies form the path to grab the content, but this way you get similar (and shorter) URLs. George Langley Multimedia Developer www.georgelangley.ca
Re: [PHP] header problem
Hi Blueman. As soon as ANYTHING has been drawn to the browser, you cannot use a header command. So you need to work through all of your code, and ensure that all of your logic that could result in a header call is run BEFORE you send any html code. Is going to be tricky if mixing html and php calls. George On 10-Sep-09, at 12:27 AM, A.a.k wrote: hello I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx'). I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is : Warning: Cannot modify header information - headers already sent by here is a simple example, user update page : if($valid) { $msg='111'; $user-dbupdate(); header(Location: /admin/index.php?msg=$msg); } else { foreach($errors as $val) echo 'p id=error'.$val.'/p'; } and on admin index i get $msg and display it. html .. //lots of stuff ?php $msg = $_GET['msg']; switch($msg){ case '111' echo 'p /p'; break; case '421':... } ? // more html and php how can i fix this? -- 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] Write Japanese text into an existing PDF
On 31-Aug-09, at 6:37 AM, tedd wrote: I used the PDFB library to create this: http://webbytedd.com/bb/pdf/ Here's a link for more information: http://chir.ag/projects/pdfb/ While I've never used Japanese text, I think as long as you have a font for it, it should work. Cool - looks like it could be used to brand a PDF with dynamic text inserted by a visitor to your site. This has potential for me! Thanks! George Langley Musician, Arranger, Composer www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: File or directory?
is_dir() http://ca3.php.net/is_dir is_file() http://ca3.php.net/manual/en/function.is-file.php George Langley On 15-Aug-09, at 5:45 PM, Clancy wrote: On Sat, 15 Aug 2009 10:33:07 +0100, a...@ashleysheridan.co.uk (Ashley Sheridan) wrote: On Sat, 2009-08-15 at 09:56 +0200, Ralph Deffke wrote: can u upload ur own files ? can u create a directory ? Yes. are u using a ftp client ? No; I'm using straight PHP FTP Clancy clanc...@cybec.com.au wrote in message news:kjhc85hpub7drihgappifphcboolt9u...@4ax.com... I have just got access to a new server, and am playing with upload/download procedures. I looked in the root directory, and see several objects which I assume to be directories. However I was surprised to find there does not appear to be any command to determine if an object is a file or directory, either in PHP FTP or plain FTP. I could try to change to them, or download them, but this seems overkill. Am I overlooking something obvious? That answer doesn't seem to quite come close even to answering the op question. Have you looked at ftp_rawlist which returns a detailed list of files, along with their permissions and directory flags? Or you could use ftp_size to determine the size of a file, which should be nothing for a directory. Thanks, Yes; I found ftp_rawlist eventually, but I still haven't found a definition of the return code, though I think I know most of it. I guess that even a null file will hve some length? I will probably use the leading 'd' in the return code to test for directories.. (And I spent a long time trying to work out how 'drwxr-xr-x 2 riordan riordan 512 Jul 31 06:40 cgi-bin' could contain lots of spaces, before I remembered that, as a result of one of the weirder design decisions, HTML suppresses trailing spaces.) -- 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] Sorting mySQL query - one order from multiple fields
In case anyone else was wondering, the command to use is COALESCE() as in: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY COALESCE(rotime2,rotime1,time)); COALESCE() will use one of the variables, being the one it finds a value for first, for each record. Note how this differs from a multi sort, which sorts by the first field, then subsorts by the second, third, etc. Hope this helps someone. George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca - On 14-Jun-09, at 8:30 PM, George Langley wrote: Hi all. Am trying to sort baseball games by time, where there can be up to 3 times listed per game. Each game has an original date and time field, plus fields for 2 rain-out dates/times (rodate1 rotime1, rodate2, rotime2), to use if the game gets rained out. Note that rotime1 and rotime2 are NULL if no time has been entered. Also note that the original date and time fields are not changed - they are kept for posterity. Usually, the rain-out date is set to a day that the teams were already going to play each other again, with the rain-out game going first. So need to sort those 2 games in order: rain-out first, then normally-scheduled. But, I can't just sort on the time field, as the rain-out game could now have a different time. I need to use the rotime2 (if it exists), else use the rotime1 (if it exists), else use the time. Can not get my query order to work. One of the variations I've tried: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY CASE WHEN rotime2 THEN rotime2 WHEN rotime1 THEN rotime1 ELSE time); Is there a query sort that will work in this case? Is not the usual sort by last name, then sort by first name scenario! Thanks for any pointers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting mySQL query - one order from multiple fields
Hi all. Am trying to sort baseball games by time, where there can be up to 3 times listed per game. Each game has an original date and time field, plus fields for 2 rain-out dates/times (rodate1 rotime1, rodate2, rotime2), to use if the game gets rained out. Note that rotime1 and rotime2 are NULL if no time has been entered. Also note that the original date and time fields are not changed - they are kept for posterity. Usually, the rain-out date is set to a day that the teams were already going to play each other again, with the rain-out game going first. So need to sort those 2 games in order: rain-out first, then normally-scheduled. But, I can't just sort on the time field, as the rain-out game could now have a different time. I need to use the rotime2 (if it exists), else use the rotime1 (if it exists), else use the time. Can not get my query order to work. One of the variations I've tried: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY CASE WHEN rotime2 THEN rotime2 WHEN rotime1 THEN rotime1 ELSE time); Is there a query sort that will work in this case? Is not the usual sort by last name, then sort by first name scenario! Thanks for any pointers. George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ! and !=
Hi all. Maybe I'm just getting confused by all the languages I'm trying to work with! But, isn't: if(!$var1 == $var2){ the same thing as if($var1 != $var2){ #1 doesn't work, #2 does. Thanks! George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca Too many choices, too little sleep.
Re: [PHP] ! and !=
Doh, of course! Just not thinking about the scope of the operator. If $var1 = 1, then !$var1 = 0 Thanks everyone! George - Original Message - From: Tom Rogers trog...@kwikin.com Date: Wednesday, April 22, 2009 17:01 Subject: Re: [PHP] ! and != To: George Langley george.lang...@shaw.ca Cc: php-general@lists.php.net Hi, Thursday, April 23, 2009, 8:30:34 AM, you wrote: GL Hi all. Maybe I'm just getting confused by all the GL languages I'm trying to work with! But, isn't: GL if(!$var1 == $var2){ GL the same thing as GL if($var1 != $var2){ GL #1 doesn't work, #2 does. GL Thanks! GL George Langley Multimedia Developer Audio/Video Editor GL Musician, Arranger, Composer www.georgelangley.ca GL Too many choices, too little sleep. Use brackets to make them the same: if(!($var1 == $var2)) { -- regards, Tom George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca
Re: [PHP] Best Practices for Hiding Errors
Thanks for all the info, everyone! Seems like the @ trick is nice for individual lines, but turning off/on every time may be bit much on a complicated page. The ini_set('display_errors', false); also has a hit, as it turns back on after the entire script has run, but seems the easier way and just the one time may not be too bad. So maybe is best to turn it off in the actual ini, and turn on only for me, based on my IP or some other flag. Thanks again! George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best Practices for Hiding Errors
Hi all! Have a question about hiding PHP errors from the end user. I have the following lines: $fp = fsockopen ($host, 80, $errno, $errstr, $timeout); if (!$fp) { // problem, put error handing code here } else { // success, do whatever here } but if fsockopen is unsuccessful, PHP will display an error warning on the page before it even gets to my error handling code. I found the display_errors command at: http://ie.php.net/manual/en/errorfunc.configuration.php#ini.display-errors but they give the following warning: This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet). Am unclear what that means - is it okay to add: ini_set('display_errors','Off'); to my page, so that an end user won't ever get the warning displayed and I can deal with the error behind the scenes? Or is there a better way to keep PHP from writing error codes to the screen? Thanks! George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Limit Local Search to Content
Hi all! Am building a Search feature following the excellent tutorial at: http://www.oreillynet.com/pub/a/php/2002/10/24/simplesearchengine.html It loops through a page and stores the words found in a mySQL database. I have about 60 pages, and all of them share a number of common items like header, menu, footer, etc. These get added as includes. The result is that every page gets marked as having Contact Us, Terms of Use or any other item in the menu, footer, etc. I would like to limit the word list to items found just in the page's unique content. I do have a div with an id of divContent for the actual content. So I could add an if statement to only start storing words found after the word divContent has been found. But, my question is: How do I STOP it? Is it permissible to add the id again in the closing div tag ie /div id=divContent. If this is allowed, I could keep an eye out for that id again and stop it when found a second time, so that my list doesn't include items in the footer (which again is common to all 60 pages) or any other items outside of the content section. Or is there a better way to trigger the recording of words on/off? Thanks! George Langley Multimedia Developer Audio/Video Editor Musician, Arranger, Composer www.georgelangley.ca
Re: [PHP] Limit Local Search to Content
2009/3/26 George Langley george.lang...@shaw.ca: How do I STOP it? Is it permissible to add the id again in the closing div tag ie /div id=divContent. From: Stuart stut...@gmail.com You can't have any extra info in a closing HTML tag. This problem is usually handled using comments. Something like the following... div id=divContent !-- content begin -- sofihsod hiosdh sdh gus us u sg !-- content end -- /div You then just start with you see the begin comment and stop when you hit the end comment. - Thanks! Will use a unique word like !-- startSearchTerms -- to make sure is located and not accidentally found within the content. George
Re: [PHP] Limit Local Search to Content
- Original Message - From: Stuart stut...@gmail.com You can't have any extra info in a closing HTML tag. This problem is usually handled using comments. Something like the following... div id=divContent !-- content begin -- sofihsod hiosdh sdh gus us u sg !-- content end -- /div You then just start with you see the begin comment and stop when you hit the end comment. - Hmm, they are stripping out the tags before looking at the words, so didn't work quite as I originally thought. The solution seems to be to explode the string based on the entire comment before doing the word-by-word storing. I wrote up the following test code that seems to work and handles any string or error I could think of. Am wondering if this is good or is there better/more efficient code? ?php function contentString($pString, $pStart, $pStop){ echo $pStringbr /; $finalArray = array(); $finalString = ; $exploded1 = explode($pStart, $pString); // makes array $exploded1 for ($i=1; $icount($exploded1); $i++) // ignore first item (0) in array { $exploded2 = explode($pStop, $exploded1[$i]); array_push($finalArray, $exploded2[0]); // array of just the wanted sections } foreach ($finalArray as $value3) { $finalString .= $value3 . ; // ensures separation between substrings } $finalString = trim($finalString); // trim any extra white space from beginning/end echo $finalString; echo br /br /; } // TEST $startTerm = START; $stopTerm = STOP; // test typical string $theString = one two START three four STOP five six START seven eight STOP nine ten; contentString($theString, $startTerm, $stopTerm); // outputs three four seven eight // test string with immediate START $theString = START one two STOP three four START five six STOP seven eight START nine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two five six nine ten // test string with error (2 STARTS) $theString = START one two START three four STOP five six START seven eight STOP nine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two three four seven eight // test string with no space between separators and real content $theString = STARTone twoSTOP three four STARTfive sixSTOP seven eight STARTnine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two five six nine ten ? Any thoughts/suggestions? Thanks! George
Re: [PHP] Limit Local Search to Content
Hi Ashley. That's what I'm doing, but want to limit what gets stored to just the content. Every page has a drop-down menu of, for instance, various cities, so I want to exclude that part of the page in my search terms. I don't want every page to think it has content on Calgary, Hamburg, Phoenix, etc. I finally walked myself through the code I had been modifying, and found that they were parsing it line by line with an fgets (rather than word by word). So was able to use Stuart's original idea of surrounding the content with an unique comment line, and setting a flag to tell whether to parse the line or not. If it found the !-- start_search -- line, it would start parsing, and stop again when it reached the !-- stop_search -- line. Is also nice that I can then specify multiple sections within the page if I need to. On 26-Mar-09, at 6:22 PM, Ashley Sheridan wrote: What about storing all of the page content in the database to start with, then searching with a mysql statement is a breeze! On Thu, 2009-03-26 at 16:29 -0600, George Langley wrote: - Original Message - From: Stuart stut...@gmail.com You can't have any extra info in a closing HTML tag. This problem is usually handled using comments. Something like the following... div id=divContent !-- content begin -- sofihsod hiosdh sdh gus us u sg !-- content end -- /div You then just start with you see the begin comment and stop when you hit the end comment. - Hmm, they are stripping out the tags before looking at the words, so didn't work quite as I originally thought. The solution seems to be to explode the string based on the entire comment before doing the word-by-word storing. I wrote up the following test code that seems to work and handles any string or error I could think of. Am wondering if this is good or is there better/more efficient code? ?php function contentString($pString, $pStart, $pStop){ echo $pStringbr /; $finalArray = array(); $finalString = ; $exploded1 = explode($pStart, $pString); // makes array $exploded1 for ($i=1; $icount($exploded1); $i++) // ignore first item (0) in array { $exploded2 = explode($pStop, $exploded1[$i]); array_push($finalArray, $exploded2[0]); // array of just the wanted sections } foreach ($finalArray as $value3) { $finalString .= $value3 . ; // ensures separation between substrings } $finalString = trim($finalString); // trim any extra white space from beginning/end echo $finalString; echo br /br /; } // TEST $startTerm = START; $stopTerm = STOP; // test typical string $theString = one two START three four STOP five six START seven eight STOP nine ten; contentString($theString, $startTerm, $stopTerm); // outputs three four seven eight // test string with immediate START $theString = START one two STOP three four START five six STOP seven eight START nine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two five six nine ten // test string with error (2 STARTS) $theString = START one two START three four STOP five six START seven eight STOP nine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two three four seven eight // test string with no space between separators and real content $theString = STARTone twoSTOP three four STARTfive sixSTOP seven eight STARTnine ten; contentString($theString, $startTerm, $stopTerm); // outputs one two five six nine ten ? Any thoughts/suggestions? Thanks! George Ash www.ashleysheridan.co.uk George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Don't Forget to Punch the Clock, Shorty!
On 12-Feb-09, at 8:55 PM, Kyle Terry wrote: On Thu, 2009-02-12 at 15:58 -0700, Richard Whitney wrote: Anyone care to try this out? Feedback welcome. http://dftpcs.com Thanks -- Hi there! The right panel is not always refreshing correctly in my Mac Safari 3.2.1 Sometimes is leaving lines through the various elements, or not drawing them at all. This is occurring mostly when I click a Submit or other button in the right panel, but also when I click an item in the left panel. It does seem to be fine until after I have added a new company to the list, and then it starts having problems. Don't know if something in your code, or just my machine acting up! But may be worth testing somewhere else. HTH. George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php