[PHP] Can php be cause a strain on a web server
Is there a case where php can become unscalable for a web sever ? If so can anyone please state to me how... Thanks George
Re: [PHP] Notification system
On Fri, Aug 7, 2009 at 10:25 PM, Jonathan Tapicer wrote: > Also, take a look at Comet Server: > http://en.wikipedia.org/wiki/Comet_(programming) > > I think that Facebook uses that and also Gmail, it tends to consume > less resources than periodical ajax calls, the hidden iframe method is > simple and works fine. To implement it in PHP you will need to use the > flush function to send data a continue processing/polling. > > Regards, > > Jonathan > > 2009/8/7 Phpster : >> >> >> >> >> On Aug 2, 2009, at 7:59 AM, Dušan Novaković wrote: >> >>> Hi, >>> >>> Does anyone has any idea how to create notification system with >>> combination of php, mysql and javascript. It should be something >>> similar to facebook notification system (when someone make some action >>> it should be automatically reported to other people on system through >>> pop-up menu or something like that). I just need some basic idea how >>> to start or if someone has some example it would be perfect. >>> >>> Thanks, >>> Dusan >>> >>> -- made by Dusan >>> >>> -- PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> I think you could have some kind if Ajax polling of a php function. To keep >> the traffic down you could set it to poll once a minute or every 30 seconds >> or so. Send a simple XML stream that could feed a defined JavaScript >> function or a bit of xslt for display. >> >> >> Bastien >> >> Sent from my iPod >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > http://www.infoq.com/news/2008/05/facebookchatarchitecture is an interesting blog on how they do it -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Notification system
Also, take a look at Comet Server: http://en.wikipedia.org/wiki/Comet_(programming) I think that Facebook uses that and also Gmail, it tends to consume less resources than periodical ajax calls, the hidden iframe method is simple and works fine. To implement it in PHP you will need to use the flush function to send data a continue processing/polling. Regards, Jonathan 2009/8/7 Phpster : > > > > > On Aug 2, 2009, at 7:59 AM, Dušan Novaković wrote: > >> Hi, >> >> Does anyone has any idea how to create notification system with >> combination of php, mysql and javascript. It should be something >> similar to facebook notification system (when someone make some action >> it should be automatically reported to other people on system through >> pop-up menu or something like that). I just need some basic idea how >> to start or if someone has some example it would be perfect. >> >> Thanks, >> Dusan >> >> -- made by Dusan >> >> -- PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > I think you could have some kind if Ajax polling of a php function. To keep > the traffic down you could set it to poll once a minute or every 30 seconds > or so. Send a simple XML stream that could feed a defined JavaScript > function or a bit of xslt for display. > > > Bastien > > Sent from my iPod > -- > 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] Notification system
On Aug 2, 2009, at 7:59 AM, Dušan Novaković wrote: Hi, Does anyone has any idea how to create notification system with combination of php, mysql and javascript. It should be something similar to facebook notification system (when someone make some action it should be automatically reported to other people on system through pop-up menu or something like that). I just need some basic idea how to start or if someone has some example it would be perfect. Thanks, Dusan -- made by Dusan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think you could have some kind if Ajax polling of a php function. To keep the traffic down you could set it to poll once a minute or every 30 seconds or so. Send a simple XML stream that could feed a defined JavaScript function or a bit of xslt for display. Bastien Sent from my iPod -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffered Logging?
On Aug 7, 2009, at 9:25 PM, Waynn Lue wrote: Hey PHPers, We've been doing sampled logging to the database in our application for awhile, and now I'm hoping eventually to blow that out to a larger scale. I'm worried about the performance implications of logging to our database on ... If you are using mysql and MyISAM tables, you can try using "insert DELAYED " method. http://dev.mysql.com/doc/refman/5.1/en/insert-delayed.html This will bulk all your inserts for writes. Thanks for the suggestions! Those both look great for what I was going to do. One other thought I had after reading those suggestions, if we're doing web server logging, we can also parse the logs using webalizer or awstats. I know apache provides file size and the URL that's being hit, but what if I want to do custom referral tracking? We append ref=foo to our links to track where people are coming from, should I look at building my own solution for that, or do existing tools like awstats suffice for that as well? You may want to investigate facebook's scribe as a logging mechanism. It's highly scalable http://www.facebook.com/note.php?note_id=32008268919 Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy
On Fri, 07 Aug 2009 06:32:48 +0100, a...@ashleysheridan.co.uk (Ashley Sheridan) wrote: ... >> How, for example, could I otherwise achieved the following effect, which >> displays an image >> with a border slightly darker than the background, and with the title and >> subtitle inside >> the border? >> >> >> >> >> >> Yanni Nx >> Sally Riordan Scholarship, 2007- >> >> >> >> >Well, your above example would just become: > > > >Yanni Nx >Sally Riordan Scholarship, 2007- > > >Notice how the amount of code has dropped immediately! Yes - all of 22 bytes! > From there, you >can use CSS to target whatever element you need to within the .pfm >class. As I already do with the table. The divs look interesting, but the tables work, so I will look into them when everything else is fixed - if I am still alive! >The images on your site would not had had titles if you'd omitted alt >tags. Where would the browser find them from to display to a blind >person? The titles (eg Yanni x, above). >True, CSS does not have constants, but that is why you create them to >cascade, so that elements inherit features from their parents. A bit >like classes in programming, where everything is either inherited from >the parent object (tag) or overridden with a new style. I can completely change the color scheme and appearance by loading a new definition file, but this would be much simpler if I did not have to encode the values into the CSS: #bodystyle { font-family: "Times New Roman", Times, serif; color: #; >Also, if you're looking for diagnostics, give Firebug a try, as it >really excels at this sort of thing. You can change styles on the fly >from within the browser window, without needing to refresh the page! Thanks, I will look into it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffered Logging?
I did some very complete logging for two major german companies on their intranet pages. an application with something like 23000 registered users and more then 5 hits a day. I did none of any kind of buffering, just raw table inserts. it never gave any problem on performance HOWEVER we did a DAILY backup AND reset of the logging tables. so the tables where never much bigger then 5 records. so if u use mySQL and the buffer technices mentioned earlier I would go with it because of the benefit not to maintain another different tool. ralph "Waynn Lue" wrote in message news:d29bea5e0908071825k73920480g598af559383ff...@mail.gmail.com... > > > > Hey PHPers, > >> > >> We've been doing sampled logging to the database in our application for > >> awhile, and now I'm hoping eventually to blow that out to a larger scale. > >> I'm worried about the performance implications of logging to our database > >> on > >> ... > >> > >> > > If you are using mysql and MyISAM tables, you can try using "insert DELAYED > > " method. > > > > http://dev.mysql.com/doc/refman/5.1/en/insert-delayed.html > > > > This will bulk all your inserts for writes. > > > > Thanks for the suggestions! Those both look great for what I was going to > do. One other thought I had after reading those suggestions, if we're doing > web server logging, we can also parse the logs using webalizer or awstats. > I know apache provides file size and the URL that's being hit, but what if I > want to do custom referral tracking? We append ref=foo to our links to > track where people are coming from, should I look at building my own > solution for that, or do existing tools like awstats suffice for that as > well? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Buffered Logging?
> > Hey PHPers, >> >> We've been doing sampled logging to the database in our application for >> awhile, and now I'm hoping eventually to blow that out to a larger scale. >> I'm worried about the performance implications of logging to our database >> on >> ... >> >> > If you are using mysql and MyISAM tables, you can try using "insert DELAYED > " method. > > http://dev.mysql.com/doc/refman/5.1/en/insert-delayed.html > > This will bulk all your inserts for writes. > Thanks for the suggestions! Those both look great for what I was going to do. One other thought I had after reading those suggestions, if we're doing web server logging, we can also parse the logs using webalizer or awstats. I know apache provides file size and the URL that's being hit, but what if I want to do custom referral tracking? We append ref=foo to our links to track where people are coming from, should I look at building my own solution for that, or do existing tools like awstats suffice for that as well?
[PHP] Re: Buffered Logging?
On Sat, 08 Aug 2009 01:46:38 +0300, Waynn Lue wrote: Hey PHPers, We've been doing sampled logging to the database in our application for awhile, and now I'm hoping eventually to blow that out to a larger scale. I'm worried about the performance implications of logging to our database on ... If you are using mysql and MyISAM tables, you can try using "insert DELAYED " method. http://dev.mysql.com/doc/refman/5.1/en/insert-delayed.html This will bulk all your inserts for writes. -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server change affecting ability to send downloaded files???
The 500 is the result of the missing content-type in the real header. Once you get a blank line in there, it thinks thats the content. The error log will likely say 'premature end of script headers'... Good mystery on why it's got the blank line though. Jerry Wilborn jerrywilb...@gmail.com On Fri, Aug 7, 2009 at 7:16 PM, Ben Dunlap wrote: > > Very interesting. Excellent debugging advice. It's giving me a 500 > > error, probably why the Rackspace techs told me to check my code: > > > > HTTP/1.0 500 Internal Server Error > > Did you get that 500 while running curl from a machine outside of > Rackspace's > network? > > If so, I'd be interested to see what you get if you run it from the > server's > command line (using 'localhost' in the URL you pass to curl). > > Have you checked your Apache error log as well, and PHP's? There will > usually > be more detail in those locations when the server sends a 500. > > Ben > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Server change affecting ability to send downloaded files???
Change to cron -i to see what other information, if any, is also being passed back. You might get some errors, or some such. Since you are getting empty files my gut tells me you aren't getting anything. Since you are actually getting a PHP 500 error, that lends me to believe that it's not some type of external influence (aka the malware thoughts). Since the code looks reasonable, I'm thinking that it may be permission related. While your code/files may not have been updated, that doesn't mean that permissions were not. Trace through your file structure and see what's going on in the ../../store/files path. Adam. On Fri, Aug 7, 2009 at 5:05 PM, Brian Dunning wrote: > Correct, the files on the server have not changed either, and have been > working fine for a long time. No funny characters. > > On Aug 7, 2009, at 4:59 PM, Adam Randall wrote: > >> Sorry for replying to myself, but the files themselves only contain >> US-ASCII characters, and no quotes, correct? Having extended >> characters in your file names might cause weirdness, and quotes will >> break your HTTP header in your code there. >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Adam Randall http://www.xaren.net AIM: blitz574 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server change affecting ability to send downloaded files???
> Very interesting. Excellent debugging advice. It's giving me a 500 > error, probably why the Rackspace techs told me to check my code: > > HTTP/1.0 500 Internal Server Error Did you get that 500 while running curl from a machine outside of Rackspace's network? If so, I'd be interested to see what you get if you run it from the server's command line (using 'localhost' in the URL you pass to curl). Have you checked your Apache error log as well, and PHP's? There will usually be more detail in those locations when the server sends a 500. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server change affecting ability to send downloaded files???
Correct, the files on the server have not changed either, and have been working fine for a long time. No funny characters. On Aug 7, 2009, at 4:59 PM, Adam Randall wrote: Sorry for replying to myself, but the files themselves only contain US-ASCII characters, and no quotes, correct? Having extended characters in your file names might cause weirdness, and quotes will break your HTTP header in your code there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server change affecting ability to send downloaded files???
Very interesting. Excellent debugging advice. It's giving me a 500 error, probably why the Rackspace techs told me to check my code: HTTP/1.0 500 Internal Server Error Date: Sat, 08 Aug 2009 00:01:10 GMT Server: Apache/2.0.52 (Red Hat) X-Powered-By: PHP/5.2.10 Content-Disposition: attachment; filename="Installer.bin" Content-Length: 23223296 Connection: close Content-Type: application/octet-stream I'm at a loss. Nothing changed in the code and it works for ZIP files. On Aug 7, 2009, at 4:57 PM, Adam Randall wrote: Can you do a commandline test with curl to see what you get back? curl -I http://url/file.php?something=here That should allow you to see what is actually being produced by the code, and if it's being tweaked in some manner unknown to you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Buffered Logging?
You don't mention what database you're using, but mySQL supports memory based tables. You can use this to insert your single page loads and then have a job that periodically inserts in bulk. Memory based tables: http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html Jerry Wilborn jerrywilb...@gmail.com On Fri, Aug 7, 2009 at 5:46 PM, Waynn Lue wrote: > Hey PHPers, > > We've been doing sampled logging to the database in our application for > awhile, and now I'm hoping eventually to blow that out to a larger scale. > I'm worried about the performance implications of logging to our database > on > every single page load, though, so I was wondering if anyone's found a > solution that does buffered logging. Essentially it would log to memory > (memcached/apc/etc), and then periodically dump to a database in a > structured format, preferrably user-defined. It's not essential that we > get > every signle hit, so I'd be fine if there was some data loss on a restart. > I started writing my own solution, and then thought I'd ask the list to see > if anyone has any experience with other tools that do this. > > My Google searches around "buffered logging" have mainly found error > logging > packages, like PEAR's Log package, or log4php. Those all seem to write to > only one particular stream at a time, with no real support for buffering it > in memory and then moving it to database. > > Thanks for any help! > > Waynn >
[PHP] Re: Server change affecting ability to send downloaded files???
> changes to the code or to the files, just one day all of a sudden any > time someone purchases a DMG, EXE, PDF, etc. they get zero bytes. I've [8<] > Has anyone ever heard of something (besides my code and my files) that > could cause this behavior? You'll be my best friend if you can help. > Thanks. That list of failing file types makes me suspect some sort of anti-malware software at the perimeter of Rackspace's network. Could also be anti-malware on the users' machines, but if this is happening to a wide cross-section of users, I'd doubt the latter. Plus, in the latter case, I would expect the users' machines to end up with no file on disk at all, but it sounds like they're getting empty files instead. You'd think Rackspace would know about potentially destructive changes to their perimeter, but my experience with their first-level support is that they are wonderfully friendly and well-intentioned but could sometimes be better-informed.* Have you been able to push through to second-level support or beyond? You might have to tweak your code a bit to support your case to Rackspace (and make double-darn-sure it's actually not your problem): for example, you could grab the return value of readfile() and write it to a log file (or just call error_log() to write it to the PHP error log). This will prove that your code is actually sending bytes across the wire. Even if your headers are wrong -- which they obviously aren't, if the code works for some file types -- your users shouldn't be getting 0 bytes if readfile() is reporting otherwise. Ben *I don't intend to bash on Rackspace here -- I'm a very happy customer of theirs for email and Cloud Servers. I always give them an 8 or a 9 on customer-satisfaction surveys, and then explain my frustration with their first-level support in the "comments" section. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] does array_slice not work on multidimensional arrays?
I worked around the issue by running the too fat multi-dimed array through a foreach{ ... if($counter <= $myArrLength) { $MyNowSlicedMultiDimArr[$key]=$value; }} , but I'd still (always!) love to hear from you seasoned PHPers on this topic (anytime actually!). I learn the most from your commentary. John Butler (Govinda) govinda.webdnat...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Server change affecting ability to send downloaded files???
Hey all -- A couple of weeks ago my online stores, on a machine I host at Rackspace, stopped delivering files that people purchase. I've used this for years, and it's always worked perfectly with all filetypes: header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'. $file_row["filename"].'"'); $size = filesize('../../store/files/'.$file_row['filename']); header('Content-Length: '.$size); readfile('../../store/files/'.$file_row['filename']); But then, all of a sudden, it only works with ZIP files. There were no changes to the code or to the files, just one day all of a sudden any time someone purchases a DMG, EXE, PDF, etc. they get zero bytes. I've asked Rackspace if they upgraded something that might produce this change but they say "check your code". The code had not been touched in years (literally). I've tried a zillion combos of different headers but I'm having no luck. Has anyone ever heard of something (besides my code and my files) that could cause this behavior? You'll be my best friend if you can help. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] does array_slice not work on multidimensional arrays?
does array_slice not work on multidimensional arrays? I have one multidimensional array, and when I run it thru' array_slice() nothing happens, that I can tell. If it does not work on multidimensional arrays, what is the *simplest* workaround? (I am already working past what was budgeted for this this script.. so I really want to avoid anything but the most newbie of hacks to achieve this.) //PHP Version 4.3.9 thank you for any reply! John Butler (Govinda) govinda.webdnat...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Buffered Logging?
Hey PHPers, We've been doing sampled logging to the database in our application for awhile, and now I'm hoping eventually to blow that out to a larger scale. I'm worried about the performance implications of logging to our database on every single page load, though, so I was wondering if anyone's found a solution that does buffered logging. Essentially it would log to memory (memcached/apc/etc), and then periodically dump to a database in a structured format, preferrably user-defined. It's not essential that we get every signle hit, so I'd be fine if there was some data loss on a restart. I started writing my own solution, and then thought I'd ask the list to see if anyone has any experience with other tools that do this. My Google searches around "buffered logging" have mainly found error logging packages, like PEAR's Log package, or log4php. Those all seem to write to only one particular stream at a time, with no real support for buffering it in memory and then moving it to database. Thanks for any help! Waynn
Re: [PHP] curl_exec not hit server
You could also try checking the SSL log. This may give hints about the problem; none of the HTTP conversation happens until after SSL has been negotiated. Jerry Wilborn jerrywilb...@gmail.com On Fri, Aug 7, 2009 at 1:16 PM, Tom Worster wrote: > On 8/6/09 2:33 PM, "Ted Yu" wrote: > > > > > Hi, > > I use the following code to call third party web service: > > curl_setopt($ch, CURLOPT_URL, $url); > > curl_setopt($ch, CURLOPT_TIMEOUT, 120); > > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); > > curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); > > curl_setopt($ch, CURLOPT_SSLVERSION, 3); > > curl_setopt($ch, CURLOPT_SSLCERT, $loc); > > curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password); > > curl_setopt($ch, CURLOPT_HTTPHEADER, $this->_httpHeaders); > > curl_setopt($ch, CURLOPT_POST, 1); > > curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlData); > > $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > > > > $xmlResponseData = curl_exec($ch); > > > > But for a specific API, curl_exec() returns true but there was no hit on > their > > server (as verified by contact in that company from server log) > > > > Can someone provide hint ? > > not me. > > but, if you haven't already, maybe try debugging by: print out the values > of > all the variables in the above code and with them (or some subset) try > making the same (or similar, or simpler) requests to the same $url using > curl the command line with verbosity or tracing turned on. > > curl might give the hint you need. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] curl_exec not hit server
On 8/6/09 2:33 PM, "Ted Yu" wrote: > > Hi, > I use the following code to call third party web service: > curl_setopt($ch, CURLOPT_URL, $url); > curl_setopt($ch, CURLOPT_TIMEOUT, 120); > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); > curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); > curl_setopt($ch, CURLOPT_SSLVERSION, 3); > curl_setopt($ch, CURLOPT_SSLCERT, $loc); > curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password); > curl_setopt($ch, CURLOPT_HTTPHEADER, $this->_httpHeaders); > curl_setopt($ch, CURLOPT_POST, 1); > curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlData); > $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > > $xmlResponseData = curl_exec($ch); > > But for a specific API, curl_exec() returns true but there was no hit on their > server (as verified by contact in that company from server log) > > Can someone provide hint ? not me. but, if you haven't already, maybe try debugging by: print out the values of all the variables in the above code and with them (or some subset) try making the same (or similar, or simpler) requests to the same $url using curl the command line with verbosity or tracing turned on. curl might give the hint you need. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] /usr/local/lib/php/20060613/imap.so: Undefined symbol "ssl_onceonlyinit"
Hi, I just installed FreeBSD 7.2, Apache 2.2, php5-5.2.10 and php5-extensions 1.3, all from the freebsd ports. When i try to start apache with the imap.so extension enabled in extensions.ini, i get the error */libexec/ld-elf.so.1: /usr/local/lib/php/20060613/imap.so: Undefined symbol "ssl_onceonlyinit"* I tried to google it, but all i get is an old error from 2002. Please help ;) Thanks, Ebbe, Denmark
RE: [PHP] Displaying user data and picture
From: Ralph Deffke > however there are some reasonable reasons to store a > image in the database. > 1. if u have no access to write files to the disk this > is the case in most free hosting services they give u > php and mysql and thats it > 2. if u want some access control to the image, e.g. login > controlled. server admins dont like u playing arround > with the htaccess file > 3. its easy in those and other cases > 4. image directores are public, and apear in search engines 5. There is a natural relationship between the images and other data already in the database, such as ID photos linked to employee numbers. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pattern Matching
Martin, Thanks! Not only did that help tremendously but it also gave me a better understand of regular expressions. Thanks! Floyd On Aug 6, 2009, at 6:15 PM, Martin Scotta wrote: here you have the regexp's = \d{8} AA = \w{6} #A? = [\w\d]* (change the * for + to require at least 1 character) ##-A#A = \d\d-\w\d\w On Thu, Aug 6, 2009 at 6:57 PM, Floyd Resler wrote: I need some assistance in pattern matching. I want allow the admin user to enter a pattern to be matched in my order form editor. When someone then places an order I want to do a match based on that pattern. Some of the examples I thought for the patterns are: - must be numeric and 8 digits AA - must be alpha and 6 characters #A? - must be alphanumeric any length ##-A#A - must have two numbers, a dash, a letter, a number, and a letter I'm sure regular expressions are the answers but I am not well- versed in those at all and I'm not sure how to make the above patterns work in or even they are the best examples to use. Any help would be greatly appreciated. Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Martin Scotta
Re: [PHP] Re: Pattern Matching
Thanks to Martin's answer to my question (giving me the regular expressions to my patterns) I can convert the patterns the admin users enter into regular expressions. Thanks! Floyd On Aug 6, 2009, at 6:19 PM, Ben Dunlap wrote: I need some assistance in pattern matching. I want allow the admin user to enter a pattern to be matched in my order form editor. When someone then places an order I want to do a match based on that pattern. Will your admin users know how to use regular expressions? If not, can you reasonably anticipate the kinds of patterns the admins might want to create, ahead of time? Or do you need to give them a really flexible way to build any sort of pattern they please? Ben -- 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] Radio buttons problem
> -Original Message- > From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] > Sent: 07 August 2009 05:43 > > > This should work: > > > > > > > > > > > > Yes, that works. But should I manually maintain the number in the > bracket? > Is there anyway so that it can be automatically maintained? Because > my app > allows to delete entries arbitrarily. For instance, consider this > layout (+ > is insert button, - is delete): > > entry1 +/- > entry2 +/- > entry3 +/- > > entry1 has sex[0] field, entry2 has sex[1] and so on. If entry2 is > deleted, > then I have to change all sex fields in entries below entry2 which > is a > waste of time. Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the resulting array with foreach, and there's no problem. (Unless your back-end logic demands sequential id numbers, but my opinion would be there's something wrong with your design if it does.) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Trying to create a comment function
> -Original Message- > From: Allen McCabe [mailto:allenmcc...@gmail.com] > Sent: 06 August 2009 20:20 [] > It was working wonderfully, until I wanted to display "test of > $newComment" > as a comment. > > [code] > > comment("test of $newComment"); > > [/code] > > This rendered a comment that said "test of ". > > So I added a \ before the $ to make it display properly, but I was > wondering > if there was a way that the function could work so that it will > display > anything you type within the quotes in comment(" "). You've already been correctly pointed at single quotes, but the other answer to this is "No", because parsing of escape sequences and interpolation of variables are done before the resultant string is even passed to the function (in the case of escape sequences, *long* before -- before your script even starts executing!). [] > After noticing that I MUST escape the dollar sign for it to display > a > function name in a comment, I tried the following: > > [code] > > function comment($commentText = "empty comment") > { > > $healthy = "\$"; > $yummy = "$"; > $newComment = str_replace($healthy, $yummy, $commentText); > echo 'Comment:'; > echo ''. $newComment .''; > > } > > [/code] > This won't work for the reason noted above. The \ character is never stored in your string -- it's there just to tell the PHP parser to treat the following $ as a literal $, not the start of a variable name. It's important to understand that escape sequences in general store a character in the string that is not what you see in the script -- so \$ stores just the $, \t stores a tab character, and so on. (And, of course, \\ stores a single \.) Hope this helps you understand why what's happening is happening ;) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: "PHP 6 and MySQL 5 for Dynamic Web Sites" Book
Hi Larry, nice to have a comment from the editor, and I want to say thanks for writing this book. however this discussion was initiated by a newbie asking what book he should use to learn php. ur book is important to the community of php freaks ! it saved my time to see where the path is going through ! without reading and surving on the web about the php6 branch. i do have ur book on 4 and 5 as well and the new book i could just use to overfly the php6 related parts and i was in the picture what COULD happen. thanks for ur work. however, for a newbie ? he would wonder why his production server tells him about parse errors of unknown construction, because its 5,x as I said earlier, "learning a family starting with a baby", however if you are familiar with the family, you should get to know the new baby. ralph_def...@yahoo.de "Larry Ullman" wrote in message news:0c4de4e7-8169-4477-8d70-25cca96eb...@dmcinsights.com... > Thanks to the OP for the interest in the book and to everyone else for > their input. So here's what happened, from the writer/horse's mouth: > It was time to write an update to the book because the second edition > had been out for 3+ years or so, I think. It wasn't a money-making > effort (i.e., get people to buy another copy) but rather a touch-up to > make sure it's current enough. I had to make some decisions about what > versions to support; the previous edition supported both PHP 4 and 5. > PHP 6 was more than 50% complete at the time I started writing it and > I thought the Unicode support was a pretty big deal, this being an > ever-increasing global web...marketplace...blah...blah...blah. So I > wanted to start thinking along those lines and as I didn't know when > the fourth edition of the book would be written, I thought I'd get an > early jump on PHP 6. Yes, PHP 6 wasn't nearly finalized at the time > and no hosting companies were using it, but many hosting companies are > still using PHP 4 and PHP 6 *is* available for playing around with. So > that was my reasoning. In the end, only a bit more than one chapter > _requires_ PHP 6 and I do like looking a bit into the future of Web > development and PHP. Also, as I don't discuss OOP in this book (gasp!, > I leave that to my more advanced PHP book because a decent discussion > of OOP requires at least 150 pages and I'd need to cut out more > important topics to include it in this book), some of the features > being discussed in PHP 6 weren't problematic for the book one way or > the other (like namespaces, which ended up on PHP 5.3). Again, the > Unicode support was my main thinking. > > Two years later, had I known PHP 6 still wouldn't be out, I probably > wouldn't have touched it at all and I do feel a bit sheepish about > having a book out there on PHP 6 when PHP 6 isn't out there (for > production purposes), but these things do happen to books, > particularly with open-source projects that have no need to adhere to > deadlines. Still, I would like to think that at worst, 10% of the > material isn't usable today on production servers but still has a > philosophical benefit. To atone for my prematurity, I do try to > support the book as much as possible, I try to talk about all this > versioning stuff in publish ways (like on the Amazon page for the > book), and I don't think there's anything wrong with someone buying > the second edition if they're a bit concerned about the PHP 6 thing. > (In theory, I guess someone could, um, buy another writer's book, but > I prefer to plead ignorance of such outcomes.) We--the publisher and > I--also did consciously change the title of the book from "PHP and > MySQL for Dynamic..." to "PHP 6 and MySQL 5 for Dynamic..." to > indicate the distinctions being made. > > Sorry for the length, but I hope that helps. And thanks again. > Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
you dont seem to understand how radio buttons work. they treat name="sex[][]" as a single group. and you can select only one element in that group. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] "PHP 6 and MySQL 5 for Dynamic Web Sites" Book
Tony Marston wrote: Don't be so pedantic. PHP 6 does not exist in a live, production-ready version. It is still under development and has not even reached the beta stage. Anyone who writes a book which documents the features of PHP 6 is being very premature as those features may change at any moment. The features will not be frozen until the first GA release. Actually has anybody seen a copy of the book? Does it cover anything other than the original roadmap for PHP6? It certainly will not have any correct examples for 'namespace' since they were not even documented at the end of 2007 ( I assume that the book took more than a few months to update an print in April 2008 ) Of cause the debate needs to be 'What is holding up an alpha release of PHP6'. Much of the talk some years ago WAS of that happening 2007/8 and at that time I had been running a PHP6 development machine for some time. It's probably 2 years since I updated it, since there was little point in doing any more testing at present? As far as I am aware the hold-up is still as to whether PHP6 should simply be native Unicode? My personal view is that this IS the correct way forward and that PHP5.?.? remains as the single byte character version in parallel? Even though 'English' is the only language I use, my customers are world wide, and while Unicode character strings can be handled quite happily in PHP5, the simple fact that you have to ask 'is this Unicode' and use a different set of functions should not be a factor nowadays? -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php