[PHP] Visit to Germany
Greetings, I'm hoping to visit the Stuttgart area* for one week ~ ten days commencing c.Friday 19 August, to visit my brother-in-law and take a short vacation. If there are any PHP-related gatherings or activities I would be interested to meet up (last time I tried, I missed out by one week...) NB My grasp of the German language is in the feeble~abysmal range, but I promise to read at least page one of my language tutorial before I come! Regards, =dn * Dettingen-unter-Teck, Kirchheim/Teck, Notzingen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['DOCUMENT_ROOT'] on localhost
Rolf, > > the document_root just doesn't show up in my phpinfo(); > > > > do windows machines have one anyway? > > I have used this var before, just not testing it locally. > > > > It normally shows up when I use phpifno on the server. Please check/compare the entries for doc_root = in the two PHP.INI files. Are they the same/given a value. NB: ; The root of the PHP pages, used only if nonempty. ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root ; if you are running php as a CGI under any web server (other than IIS) ; see documentation for security issues. The alternate is to use the ; cgi.force_redirect configuration below ;doc_root =;; Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse Errors
Andy, > I am a PHP beginner so this error may be a stupid one. Anyway, I'm > trying to write a simple addition script. The client enters two numbers, > then my script (adder.php) adds them. However, when the script is run, I > get "Parse Error On Line 3" I have no idea exactly what I have done wrong. > Here is the script. > > print ("Your first number is:$firstnumber\n") > print ("Your second number is:$secondnumber\n") > $answer=$firstnumber+$second number > echo ("The answer is: $answer\n") > ?> > > Any help would be greatly appreciated. Thank you. PHP code lines must end with a semi-colon (;). Also, HTML newlines are (not \n) Some PHPs won't like the short tags, recommend: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Difference between 2 Dates
Colin, > I have a similar problem. I am trying to figure out which of two dates > is greater. Both are in the -mm-dd format. Is there any easy > function that allows this sort of comparison or am I missing something? Treat the dates as strings not numbers: $DateOne = "2002-12-13"; $DateTwo = "2001-11-12"; if ( $DateOne <= $DateTwo ) echo "DateOne comes first"; You can do comparisons like this but don't try any 'arithmetic'! Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ExpertRating launches PHP Certification Exam
I must be a suspicious character, but I haven't come across Expert Rating before, nor do I know what Pete's connection with Expert Rating is, so I went and looked at the PHP web site (where we are led to believe that we would expect to find "a lot of excitement") but a site-wide search fails to yield a single hit. Ok I'll go straight to the horse's mouth and look at their own web site, where I get to thinking about a certification body in the UK (based in Bristol) that has its prices set in USD. Question: who has achieved this distinction and how many employers have commented that the Expert Rating evaluation was the MAJOR selling point? =dn > Good news for the PHP developer community- > http://www.expertrating.com";>ExpertRating, the global > skills assessment provider has launched an online PHP Certification > exam. Candidates who pass the exam will be mailed a hardcopy certificate > of > accomplishment. The launch of this exam has generated a lot of excitement > in the PHP developer community. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Proposal: New list etiquette/rule
Spam Arrest Sender VerificationYesterday we held an amusing discussion which highlighted the futility of using (badly implemented) technological 'solutions' to a social problem... Herewith I attach a response received pursuant to a list contribution. Does this 'gentleman' seriously expect every list contributor to provide him with a personal service requesting permission to be allowed to post to him? What happens if dozens of his colleagues join up? BTW I will, happily, for my hourly fee (minimum charge four hours)! Suggest that the list 'rules' be updated to point out that such requirements are unlikely to be received favorably, so if he wants to join the community he needs to do 'join' us (not vice-versa). NB I know that technically I've broken my/the list's rules by reproducing this in HTML, and have done so that those who can, are able to see the stupidity in its full glory/know which service NOT to use... Regards, =dn - Original Message - From: Kadir To: [EMAIL PROTECTED] Sent: Thursday, December 12, 2002 11:51 AM Subject: RE: Re: [PHP-DB] Formatting txt from a database (verification) Kadir here, I'm protecting myself from receiving junk mail. Just this once, click the link below so I can receive your emails. You won't have to do this again. http://spamarrest.com/a?33905301:611961 You are receiving this message in response to your email to Kadir, a Spam Arrest customer. Spam Arrest requests that senders verify themselves before their email is delivered. When you click the above link, you will be taken to a page with a graphic on it. Simply read the word in the graphic, type it into the form, and you're verified. You will only need to do this once per Spam Arrest customer.
Re: [PHP] mail() problem
i setting php.ini [mail function] ;For Win32 only SMTP = hermes.ica.gov.co sendmail_from = [EMAIL PROTECTED] =it is impressive to see that the Greeks' messenger has made it all the way over to Colombia! Wasn't he also held responsible for dealing with people who were guilty of indiscreet speech - good name for an email server... =I'm immediately suspicious of the sub-domain address for the SMTP server. What do you have for server identification in your email package? Make the two definitions the same. =Whereas this might be the name of your MS-Exchange box, what happens if you remove the "hermes." and just go with the domain name? =Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filter vulger / controversial words - need word source
Jason, > > there simply is no definitive list of words > The fact is content filtering does not work without a heavy dose of human > intervention. > It is quite shocking that large numbers of well known corporations deploy > misconfigured content-filtering software which rejects perfectly innocent > email. Earlier contributions highlight this admirably. I was at an "Information" show last week where a stand displayed the good work of the EU organisation in the field. I spoke to a Brussels(*) wonk/weenie/suit about such legislation (proposed and awaiting national enactment). I suggested that it would be unfair to 'bring to justice' anyone for apparently offending some employee/user's sensitivities without first defining WHAT would cause offence (eg the requested list of "vulgar words"). Otherwise the first you might know about it is when a court decides (against you) that is unacceptable in polite company. Accordingly I suggested that his department publish such a list (in all of the languages/cultures of the EU???), but observed that he would have a serious problem being able to distribute it without his own office prosecuting itself! As is to be expected, he failed to see the humor (and failed to see the sense/requirement to do so)... The joke is on our Indian friends @upv.pertamina.co.id whose 'filter' simply bounces messages containing "Dirty Words", because as you say there is no human involvement so they can't even benefit from Jon's observations. This policy means that every contact/contract with Sc*nthorp that they lose, is deservedly so, and an unfortunate advertisement not to use that country for out-sourcing if the culture-gap is so great!? Summary attitude: hey I'll code it if you want it/pay me to do so, but what are you going to do when you meet the rest of society as soon as you come off the email system? NB it has 'always' been illegal to use such language in (British, and many others) phone conversations, but who does that stop/what filters are in place there? =dn *for the benefit of more distant members: Brussels is the home of many European Union (EU) offices, and the source of much bureaucratic 'stupidity' such as the legislation mentioned earlier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filter vulger / controversial words - need word source
> > if you want a partial list of offensive terms - try looking > > at the meta keywords on a few porn sites ... > > Excellent idea! > Unfortunately I'd have to explain that to my boss... "No, really, I'm doing > some research..." =guess monopolising the color printer for a whole afternoon would give you away, huh? =but won't your gateway/web server's filter prevent access to such sites anyway? =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() on two diff. servers
Mike, No complaints about explanations in PHP manual - I often say that it IS a cut-above the average. However it does NOT explain the underlying concepts of "timestamps", (quite rightly) expecting that we pick up such from other/more appropriate sources. Hence my comments are refering to such sources/attempting to find such sources... Like you, when I re-read that entry in the PHP manual (after your informative reply) I 'saw' the logic and discovered that I had to move the 'location' in my mind-map where I had framed the GMT/TZ adjustment. Fortunately it didn't nullify any design decisions I've made/relied upon. Unfortunately *NIX sources thus far consulted don't seem to feel it necessary to do the same/print anything confirming (and many of them most careless in your "GMT" point) - and hence the discomfort. It is always difficult to learn new things, and if not more so, can be v.awkward trying to adapt from one philosophy to another, eg Windows to *NIX. Getting the terminology straight is one thing, getting the model worked out another. I don't doubt what you say/am happy to be shown to be wrong, but would sure like to 'prove' it. As I say, am probably just barking up the wrong (Christmas) tree(s). No worries - it's familiar territory! Thanks for your help, =dn > > -Original Message- > > From: DL Neil [mailto:[EMAIL PROTECTED]] > > Sent: 10 December 2002 19:52 > > > > =as a Windows user I struggle to cope with some of these UNIX > > concepts, so I > > hit Google - with no joy, and ripped through the SuSE manuals > > (I'm a closet > > Linux user - will become one, just as soon as I can find the > > necessary spare > > machine (and time!) - till then, the box of manuals, CD-ROMs > > etc lives in > > the closet!) Would you believe, none appear to clarify this > > (maybe I'm using > > the wrong terminology/barking up the wrong trees...). > > Well, I think the PHP manual is pretty good about this -- all the pages I've > looked at are careful to add the GMT timezone indicator when referring to > the base date of the Unix epoch, which is pretty much what tipped me off to > the correct interpretation. (If you find a reference there that doesn't > include the GMT indicator, I reckon that would be worth a bug report in the > Documentation problem category.) > > Cheers! > > Mike > > - > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information Services, > JG125, James Graham Building, Leeds Metropolitan University, > Beckett Park, LEEDS, LS6 3QS, United Kingdom > Email: [EMAIL PROTECTED] > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filter vulger / controversial words - need word source
Hi Jon, I think we've seen this discussion on the list before (so Christopher, check the archives!) > > I'm wondering if someone has a great source for a master-list > > of controversial and vulger words that I can use on my site. > > I would like to pattern match input text against this master-list > > in order to prevent vulger and controversial words from appearing > > on my site. > Once you've got the routine working, post it here, because there are many > people who would like to know how to do this properly. > The problems that others have experienced in the past are: > - what happens with "mis"spellings, e.g. "fsck"? > - what happens with dodgy formatting, e.g "f s c k"? > - what happens with words like "Scunthorpe"? Problem 1: add likely/popular mis-spellings to the list of vulger/vulgar language Problem 2: (contrived) very few single-letter words exist so remove intervening white space prior to analysis Problem 2a: (the more popular f*ck - someone suffering the misapprehension that (s)he is somehow NOT guilty of using bad language/being offensive when (s)he plainly is not only doing so but attempting to be deceptive as well...) see response to Problem 1 (the probably habit would be to replace/remove vowels) Problem 3: Scunthorpe contains an unfortunate series of letters (amongst the town's many disadvantages) however the critical four are not a word in and of their own right so employ whitespace (\s) in the RegEx or token analysis. > May I suggest, rather than picking your way through this minefield, you > provide a "report abusive comment" link instead? Most sensible! The employment of a technological solution to a social problem is somewhat shooting the messenger. However some countries are now legislating responsibility that ISPs/employers must discharge (shooting the person who shoes the horses that the Pony Express messenger is riding!?) In this case perhaps one could analyse the incoming text and place an embargo on its publication on the web site until it has been reviewed by a human editor? If we were talking about filtering incoming email, then perhaps the original message could be forwarded/wrapped with a message from the EmailAdmin/System pointing out that a message has arrived from xyz (etc) and has been flagged for a stated reason (but that there is room for interpretation within the mechanical observation) and that the message should not be opened by anyone fearing offence. (this similar to 'security' gateways that don't allow msgs with attachments unless the 'employee' first authorises a 'pass-through') Euro 0.02's worth? =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Script not working from one computer
> > > I have a feeling it's going to work out to be something stupidly > > > simple... like these problems always do. :) > > =embarrassingly so! If you're taking this all off a user's say-so, > then it > > sounds like an eyeball job to me... > I never did solve it, but it came down to a weird cookie problem. The > Session cookie was being set and accepted correctly, but regular cookies > would never set. Other web sites could set cookies, but none from this > web site were ever written. I don't know if it's because of SSL or what. > It's one of those things that worked fine yesterday and now doesn't work > and the user "didn't do anything." Oh well... IE allows quite a bit of control over the handling of cookies. Most admins would probably focus on the "Security" tab and the possibilities it offers. However there is also a vicious back-hander under the "Privacy" tab (that you can't see/get no warning about, under normal operation) and with a simple command one can ban cookies from any nominated web site(s) - hence everything works fine for accessing (eg) the NYTimes but blows up in your face (sorry SeaBee humor) when you access the nominated site. Could be done by FOBCAK, user brilliance=ignorance, or deliberate sabotage/cynical Admin baiting! Couldn't access various online purchasing sites from a hardened laptop, so if they didn't say that they required cookies and I called their HelpDesk, much going round-and-round resulted... Herewith another argument for keeping sessions/controls exclusively server-side! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fgetcsv Help
Richard, > I am parsing a csv file with fgetcsv and the fields are surrounding by > double quotes, now I am running into a problem periodically that when there > are quotes within the value it is treating it like another value instead of > the same value. > Any ideas on how to get around that? > > I am thinking I might have to convert all quotes to " and then turn all > "," back into quotes and then the first " in the file and > then last one since obviously they will not have a comma in between them. > This seems like a while lot of work.. > Ideas? The first idea is that the system that outputs a .CSV with quotes within a quoted field is broken big-time and that's the part that needs fixing! I'm on the same wavelength as you describe: you can't use any automated csv function on such a file. Quotes <> only appear in pairs. The closing quote must therefore appear immediately prior to a field separator (eg comma) - whitespace not withstanding, unless it is the last field on a line, in which case it will appear immediately prior to a record separator. One possibility is to write a 'filter' script to do this - and thus leave your existing code intact. The filter could take in the file, explode on quotes, and then cycle through the resultant array looking at the first non-whitespace data in every second element, clean/recode where necessary, and then implode and output. Alternatively could join/unset consecutive array elements which have been split inappropriately (by 'internal' quotes), and then implode using the other style of quotes/another separator, if this can be made to work later in the process... What a palaver! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem relating to images in email
Hello khuram, > Iam new at this mailing list . =welcome to our happy band! I have a problem in php > is that i want to store the images on local hard disk > that are in email (pop3 account) by runing a php file. > how can i do that. please help me asap. =there are a number of classes available that you can absorb into your project. I use email classes from PHPguru.org. =In this case it seems that you will require the ability to first read msgs off the POP server (also check out PHP's IMAP functions), then split them into components, then identify the MIME encoded graphics and store them away. Haven't done all of that myself, but it sounds 'easy' enough... =Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() on two diff. servers
> > =now let's take a look at the UNIX Epoch. Various > > 'quotations' have surfaced > > in this email, and I don't recall that it is well discussed > > within the PHP > > manual (it being a UNIX definition after all...). The epoch 'began' > > 1Jan1970, sure enough (exactly as quoted). HOWEVER it is defined as > > beginning at Greenwich: 1Jan1970 at midnight UTC in Greenwich... > > > > =So a timestamp of 'zero' in London (UTC) would see the east coast of > > Australia at 39600 local (TZ of +1100 (hours)). > > Er -- no, I think you've got that backwards. Unix timestamps are, as you > rightly say, seconds since 00:00 1-Jan-1970 GMT, so, at any instant, the > Unix timestamp is the same at every point on the globe. It's only the > *local* *times* (on the server, of course) that change. So, the Unix > timestamp of 0 represents: > >00:00 1-Jan-1970 GMT >19:00 31-Dec-1969 on the east coast of Canada/USA > (5 hours behind GMT) >09:30 1-Jan-1970 in Australia's Northern Territory > (9.5 hour ahead of GMT -- I know this > one 'cos my sister lives there!) > > From this, you can see why the same time stamp might give you different > dates if your servers are in different timezones -- espacially ones as > widely different as Australia and Canada! =which is about where we came in, IIRC > > =if at that very time I was in London and you in TZ+1100 and > > we waited one > > hour, the asked for the current timestamp: I would get 3600 > > and you 43200. > > Again, no: if I, at 01:00 local in GMT, and he at 12:00 local in a GMT+1100 > timezone -- that is, the very same instant -- both asked for the current > UNIX timestamp, we would both get the same answer. =uh-oh. I may misunderstand UNIX timestamps then - perhaps I am assuming too much similarity to date()? =Date() is local-TZ aware, so I appear to have assumed that a timestamp is also. What you are saying is that a timestamp is always GMT (regardless of machine/opsys TZ) and only when passed to date() or somesuch is the 'time' value manipulated (as well as its format) to become local. Correct? I thought timestamps were set at the time on the local clock, and thus would be different across TZs - date() is... =as a Windows user I struggle to cope with some of these UNIX concepts, so I hit Google - with no joy, and ripped through the SuSE manuals (I'm a closet Linux user - will become one, just as soon as I can find the necessary spare machine (and time!) - till then, the box of manuals, CD-ROMs etc lives in the closet!) Would you believe, none appear to clarify this (maybe I'm using the wrong terminology/barking up the wrong trees...). =Like you (Mike), I'm living in Zulu-TZ (although unlike you, I'm not always 'here'), where it's not so easy to test for myself (and I'm not prepared to jump onto client machines to 'play', at this moment). - I double-checked with Asia this morning and things work exactly as they should (at the application level) so I'm (relieved) confident that all is well with the code. =So as far as any processing goes, whatever I understood was the 'model' was good enough to get the job done, however my 'model' of the way UNIX/PHP works is slightly shaken, so I'm not a happy bunny... =With relief that I didn't mislead Justin: the fact remains/we are completely agreed - if you want to have a consistent database (for example) with temporal data arriving from/going to different TZs, then the gm*() functions are the ones that will offer the required international consistency to convert timestamps to readable dates and v-v... > > =The reality is that everyone works off UTC (NB "GMT" whilst widely > > used/terminology within PHP is not the "internationally PC term") - > > including the (alert) Americans - the US military > > refers/referred to UTC/GMT > > as "Zulu time" (which has more to do with the alphabet than > > warriors). So if > > I'm in Germany and I'm phoning you early/late in the day, to > > avoid holding > > our conversation in a less socially-acceptable climate I > > would first compare > > my time against UTC (+0100) and then compare your time > > against UTC (+1100), > > do the math to get a difference of +10 hours, add that to my > > local time, and > > thereafter place/delay the call... (try doing this > > calculation based upon > > something like Indian Standard Time, and add a Daylight > > Saving/Summer-Time > > adjustment into the mix, just for 'fun'!?) > Well, the time/date functions provided in PHP can do all this for you. =and do so, very nicely, thank you! > > =In conclusion, (based upon my, cough, cough, many years of > > wrestling with > > this sort of thing) make all stored times UTC (gm*()) > Yes -- as the Unix timestamp is an *absolute*, always expressed in GMT > regardless of where you are (or, rather, where your server is!), this is the > one to use as your base. > > - the > > RDBMS should not > > 'filter' timestamps - MySQL does not (
Re: Re[2]: [PHP] Script not working from one computer
John, > > > You mention that it is a login script and that input is rejected. Is > it > > > rejected when it is initially typed in, or is it reported as > rejected > > when > > > ensuing pages are served? > When it's initially typed in. =do you have multiple 'environments' (eg VHosts or even physical servers) on your PHP/web server? If you run the errant machine against a copy of the script in another 'environment' does the same happen? =can you put a DEBUG line into the code and have the data displayed prior to it leaving the PC/form, and as the login 'result' is being processed/returned to the user? Where does it 'break'? =is there anything silly about the person's login/pswd? Is it just the one person's login that's at issue, or everybody's when they use that particular PC-client? > > > Please check the IE on the offending machine. Does it have security > > > settings that forbid cookies? > No, it's a default install of IE6. I have a check that'll put up an > error if cookies are turned off and that's not the error I get. I get > the error saying that the username or password didn't match anything in > the database. =not something dopey like a zero-oh transliteration error, eg passw0rd instead of password? > > > Check the ipconfig/all settings against other machines/check any > > contents > > > of HOSTS file (and the other MS one, if used) > > > > > > Check execution of phpinfo() against similar on other/working > machines. > > > > Is it a plain old login script, or is it one which uses javascript to > MD5 > > the > > password? If the latter, you may want to check you've enabled > javascript. > > It's just a plain log in script. > > I'm going to troubleshoot it more today and throw in some tracing to the > functions to see where everything is going and what the login/password > values are all the time. I just haven't had a chance to make it over to > that computer yet. > > I have a feeling it's going to work out to be something stupidly > simple... like these problems always do. :) =embarrassingly so! If you're taking this all off a user's say-so, then it sounds like an eyeball job to me... =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Different output on two different servers
Hi Steve, Have you solved this already? If not, when you copied the code between machines was there some effort to ensure that the 'copy' points to the RDBMS/tbls on the same box/different box - or does the original box have code that points to tbls on itself, and the second box have code that runs on 'it' but (still) points to tbls on the first box (not on itself)? [make sense?] Regards, =dn PS what's the difference between "production" and "live"? (in my jargon they are synonyms) > I have set-up a production server and a live server. The problem is with > the production server. I am using PHP version 4.2.3 and MySQL 3.23.39 on > both servers. We have just configured the production server to mimick > the live server (which incidentally works fine) and the code from both > servers is identical. I dumped all the data into the production MySQL > database then copied the code from the live server to our production one > and there didn't seem to be any problems. However today my boss asked > for a new category to go into our webshop with a new product. I went > into MySQL and updated the database fine then when I went to check the > section of the site to see if the extra category and product are there I > get my own PHP encoded error 'No categories currently available'. It > fails on the first function: > function display_categories($cat_array) > > { > //display all categories in the array passed in > if (!is_array($cat_array)) > { > echo "No categories currently available."; > } > else > { > //create table > echo " background='images/shopbg.gif'>"; > etc. > > Now it works superbly on my live server and did work fine until I tried > adding another field to the database on the production server. Where > should I start looking to de-bug this? > > Steve Jackson > Web Developer > Viola Systems Ltd. > http://www.violasystems.com > [EMAIL PROTECTED] > Mobile +358 50 343 5159 > > > -- > 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] How to test php.info from command line
I agree with Jason, it seems strange to have a command line option (that can only apply to command line operation) and yet the output be in browser/non-command line format... However with PHP-CLI 'coming soon', maybe that sorts things out. Meantime may I suggest combining the two answers: php -i >/tmp/test_php.html (note file type) Thereafter chuck test_php.html into your browser for convenient viewing/to 'get rid' of the tags/static. (when I do this, the graphics don't print out, eg PHP logo at page top - which is a convenient way of differentiating between phpinfo() from the command line and from a web server!) Hope it helps, =dn > > >How to test php.info from command line: > > > > #echo "" | php > > > > to the standard output (screen) - or if you want to a file like this way: > > #echo "" | php > /tmp/test_php.txt > > > > Oliver Etzel > > > > .eu - domain are coming soon > > www.t-host.com > > Or simply > > #php -i > > It would be nice if there was a text-only version without all the HTML gunge. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Script not working from one computer
Hi John, You mention that it is a login script and that input is rejected. Is it rejected when it is initially typed in, or is it reported as rejected when ensuing pages are served? Please check the IE on the offending machine. Does it have security settings that forbid cookies? Check the ipconfig/all settings against other machines/check any contents of HOSTS file (and the other MS one, if used) Check execution of phpinfo() against similar on other/working machines. Regards, =dn > Tuesday, December 10, 2002, 2:31:48 AM, you wrote: > >> Have you checked: > >> > >> Browser versions? (is the browser the same type/version as on the other > >> machines) > >> Is it a laptop? If so, are you using the internal keyboard with Numlock > 1JWH> on? > >> Is the machine in question set-up on the network correctly, i.e. has it > 1JWH> got > >> domain, gateway addresses etc setup - this would only affect it if the > >> Intranet server is set-up to only allow a certain range of IP addresses or > >> doamin/hostnames etc. > > 1JWH> Browser's are the same (128bit). It's not a laptop. The web page can pull up > 1JWH> any other external web page correctly. > > 1JWH> What gets me is that the computer can pull up the log in page. It can pull > 1JWH> up another, unprotected page from that web server. But, no matter who tries > 1JWH> to log in from that machine, I get a bad username and password, even though > 1JWH> they are right. It's like the browser is sending bad data to a script that > 1JWH> works fine from every other computer. > > 1JWH> Anyone else have any other ideas? > > 1JWH> ---John Holmes... > > >> I know, PHP is executed server side, so it shouldn't matter about the > >> computer, but... > >> > >> I've got a basic log in script that takes username and password and does > 1JWH> the > >> typical SELECT to find a match. If it's good, it sets some session > 1JWH> variables > >> and redirects to a main page, otherwise redirects back to the login page > >> with an error message. > >> > >> The script works from all computers but one. The login page will come up, > >> but no matter what, it says the username and password are bad. They are > >> correct though, caps lock isn't on, etc. I've cleared the cookies and > 1JWH> cache > >> and it still does the same thing. > >> > >> The script is on an intranet. One computer that had this issue was fixed > 1JWH> by > >> using https://computername.company.army.mil instead of just > >> https://computername. But for this computer, both addresses give the same > >> result. > >> > >> So, I'm sure it's not the PHP script, so I'm looking for ideas of what I > >> should check, settings wise, on the client computer? Any help is greatly > >> appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Snoopy Class
Hi UberGoober, Thanks for your (unique) reply. Specifically: am playing with web pages/link continuity checking and suchlike. So HTTP; as an improvement over the facilities offered by fopen(). Have worked through the readme examples, and dived into the script's code, as you would expect. Was hoping for something that explains in a little more depth, eg why this combination/sequence; to see if there is more that I can learn and/or more that I am missing/can make use of... - being ignorant allows me to pose the question, but by definition, not to define an answer for you! Any pointers to material, or advice from your experience would be most welcome, =dn > A tutorial to help you do *what* exactly? > The readme provides plenty of examples: > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/snoopy/Snoopy/README?rev=1.6&; > content-type=text/vnd.viewcvs-markup > > > > (pardon the pun) > > Please recommend a Snoopy tutorial, > > =dn > > PS Google has not been my friend! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() on two diff. servers
Justin, Jumping in late... > >> Daylight Savings Time? > > John, I think "Daylight Saving Time" creates a difference of 1 hour and not > > 1 day :) > True... but I checked it anyway -- by adding just one and two hours to the > stamp... which made no difference... but when I added 86400 to the stamp, it > all worked. =depends upon the time of day! (its a logic 'twister', like saying even a stopped clock is correct twice per day) > > Justin, it depends how you got your "timestamp" in the first place, I > > think... > > I could be wrong again here but aren't these different? > > mktime() > > gmmktime() =absolutely! One just 'works', the other relates everything back to GMT before performing the same calcs. > Actually, they were created with strtotime(). Note, I don't believe there's > anything wrong with the stamp itself. The point is, the stamp is displaying > as two different dates using date() on two different servers, and I believe > this is not what date() is supposed to do. > Shouldn't the stamp for 12-09-2002 22:13:09 be the same on every server? =yes, no, not necessarily! > My rationale for this is that no matter where you are in the world, it is > always a certain number of seconds since 01-01-1970 00:00:00. =yes, no..., watch out for the interpretations that are applied EVERY time you call a function! > Perhaps strtotime() is NOT running off GMT, and perhaps date() is... there > has to be SOME confusion there -- either on my side, or in my choice of > functions, or SOMETHING :) =any call to system time will get you the time that has been set on the SERVER (although there is a PHP function for local-time, somewhere - have never used it). So the first question is, where is the server? The second question is, what time zone (TZ) has it been set to run within? (NB you can run a server in Sydney, but set its clock so that it 'appears' to be in Perth - if you really want to...) =now let's take a look at the UNIX Epoch. Various 'quotations' have surfaced in this email, and I don't recall that it is well discussed within the PHP manual (it being a UNIX definition after all...). The epoch 'began' 1Jan1970, sure enough (exactly as quoted). HOWEVER it is defined as beginning at Greenwich: 1Jan1970 at midnight UTC in Greenwich... =So a timestamp of 'zero' in London (UTC) would see the east coast of Australia at 39600 local (TZ of +1100 (hours)). =if at that very time I was in London and you in TZ+1100 and we waited one hour, the asked for the current timestamp: I would get 3600 and you 43200. So whereas I can subtract zero from current time and get one hour, you must subtract 39600 from 43200 to get the correct answer - in other words, don't use "zero", but 'Epoch-zero' adjusted for TZ. =as soon as you start to twist your mind around all this, you realise why Dr Who was a bit loopy about the size of telephone boxes, etc! Time travel is not for the faint-hearted (nor the mathematically-challenged/regular lottery ticket purchasers)! =PHP provides a solution in the gm*() series. The best/only solution is to find a common timebase. I've worked with American (and one Japanese) companies who (initially) insisted on time-basing everything to HEAD OFFICE (caps to demonstrate scale of self-importance, eg "this report must be in by 1700 in ..."), and usually they end up tripping themselves up, and thus provide me with the 'proof' of the illustrations/arguments I made at the design stage (that they chose not to listen to...) =The reality is that everyone works off UTC (NB "GMT" whilst widely used/terminology within PHP is not the "internationally PC term") - including the (alert) Americans - the US military refers/referred to UTC/GMT as "Zulu time" (which has more to do with the alphabet than warriors). So if I'm in Germany and I'm phoning you early/late in the day, to avoid holding our conversation in a less socially-acceptable climate I would first compare my time against UTC (+0100) and then compare your time against UTC (+1100), do the math to get a difference of +10 hours, add that to my local time, and thereafter place/delay the call... (try doing this calculation based upon something like Indian Standard Time, and add a Daylight Saving/Summer-Time adjustment into the mix, just for 'fun'!?) =In conclusion, (based upon my, cough, cough, many years of wrestling with this sort of thing) make all stored times UTC (gm*()) - the RDBMS should not 'filter' timestamps - MySQL does not (for example), and then if you want 'local' times you can 'do the math' for either the server's TZ or (if you're really masochistic (?is that the word?)) the browser-client's local time. The 'silver lining' is that you can now easily accommodate temporal input/presentations to/from anyone, anywhere in the world - it is also easy to produce code to calculate the server's local time (for example), so that the same routine works regardless of where the server is located - where next year's new 'mirror' is to be located, anywhere
[PHP] Snoopy Class
(pardon the pun) Please recommend a Snoopy tutorial, =dn PS Google has not been my friend! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Simple text editor for Windows?
Hi Tom, > >> I know the text editor question has been beat to death, but I'm looking > >> for a simple editor with syntax highlighting that can be installed in > >> Windows by a general user. It would have to be something that didn't > >> access the registry, as normal users can't do that. Does anyone know of > >> a program like this? Thanks. > > Take a look at this one it seemed to be pretty good, the closest I've seen to > homesite functionality without the bloat. > http://www.crimsoneditor.com/ Looks interesting - and no registry finagling you say! One expects that John meant PHP syntax highlighting. From where is the PHP control file made available? Please advise, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Failed to install Mod_cURL under Windows/Apache
PHP v4.2.3 with Apache 1.3.24 under Win2000 Prof SP2 Downloaded the full v4.2.3 zip package/Win binary, some weeks ago. Installation went fine. Extensions are happily included. Have had several weeks of operations. Decided to install cURL to do some URL (strangely enough) link verification-checking. Started at manual: XII. CURL, Client URL Library Functions with sent me to http://curl.haxx.se and in turn http://curl.haxx.se/libcurl/php/ Downloaded curl-7.10.2-win32-nossl which (really) only contains CURL.EXE. I cannot see any instructions telling me what to do with this/where to put it!? Moved it to the same location as PHP.EXE. It runs happily from the command line (so that's something!) Moved both the .dlls around, checked the MVC file, and uncommented the PHP.INI line - and verified it with PHPINFO(). However when a PHP script (copied straight off the PHP manual) calls curl_init () it causes Apache to crash: "Apache.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created." - restarting the Apache service and re-running results in the same error - rebooting the whole system and re-running also. - the v-server's error log shows nothing and the access log only shows the PHPINFO() mentioned - there's nothing in the Windows Event log - I can't figure out where this "error log" is created Help! I've missed something... =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() problems...
Anthony, > I'm not sure I understand. =that makes one more! This feature is a bit of a minefield - but once you get a handle on it, its too useful to be without... > I had this working a few months ago by changing the php.ini settings to: > SMTP = localhost ;for win32 only > sendmail_from = [EMAIL PROTECTED] ;for win32 only > and I was able to run that script on my box and get an e-mail returned to > me. > Now, I getting a "failed to connect". > I'm using MS OE5. =this can only work if: a) there is an SMTP server on the localhost (and the DNS finds it), or b) the code wrapped around mail() specifies a valid and reachable SMTP server, or c) the code sidesteps the PHP mail facility completely by doing something else, or d) its not a Win box (and needs a completely different approach) =if it was working, it was working; I'm not sure what has been updated/replaced since - but let's not even go down that track. =I assume that the Win98 machine has outbound email working from some MTA, eg Outlook [Express]. Check its definition for an SMTP server. Cut-and-paste from there into PHP.INI. =also (because I'm a simple boy), forget all the optional headers etc, just use a stripped down/simple email stub-script for testing/proving. =If PHP's mail() can be persuaded to work, thereafter it (and any scripts) can be 'tweaked'/made better - or we can look back and compare... =dn > - Original Message - > From: "DL Neil" <[EMAIL PROTECTED]> > To: "Anthony Ritter" <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Friday, December 06, 2002 10:37 AM > Subject: Re: [PHP] mail() problems... > > > > Anthony, > > > > Do you have an SMTP server on your Win98 localhost? > > Recommend you change the PHP.INI SMTP= to say the same as your email > > package's server definitions. > > > > =dn > > > > > > > > > I'm using MS Win98 and Apache and getting the following after submitting > > the > > > mail form: > > > .. > > > Warning: Failed to Connect in c:\program files\apache > > > group\apache\htdocs\send_simpleform.php on line 14 > > > > > > > > > The html and php scripts follow along with my php.ini settings. > > > > > > Any help would be appreciated. > > > > > > Thank you. > > > Tony Ritter > > > > > > The following e-mail has been sent: > > > Your Name: > > > Linda > > > > > > Your E-Mail Address: > > > [EMAIL PROTECTED] > > > > > > Message: > > > Test > > > . > > > > > > > > > //this is the html form > > > > > > > > > > > > Simple Feedback Form > > > > > > > > > > > > > > > > > > > > > Your Name: > > > > > > > > > Your E-Mail Address: > > > > > > > > > Message: > > > > > > > > > > > > > > > > > > > > > > > > > > > .. > > > //this is the php script > > > > > if (($sender_name == "") && ($sender_email == "") && ($message == "")) { > > > header("Location: http://localhost/simple_form.html";); > > > exit; > > > } > > > $msg = "E-MAIL SENT FROM WWW SITE\n"; > > > $msg .= "Sender's Name:$sender_name\n"; > > > $msg .= "Sender's E-Mail: $sender_email\n"; > > > $msg .= "Message: $message\n\n"; > > > $to = "[EMAIL PROTECTED]"; > > > $subject = "Web Site Feedback"; > > > $mailheaders = "From: My Web Site <> \n"; > > > $mailheaders .= "Reply-To: $sender_email\n\n"; > > > mail($to, $subject, $msg, $mailheaders); > > > ?> > > > > > > > > > Simple Feedback Form Sent > > > > > > > > > The following e-mail has been sent: > > > Your Name: > > > > > > Your E-Mail Address: > > > > > > Message: > > > > > > > > > > > > > > > My php.ini settings are: > > > > > > [mail function] > > > SMTP = localhost ;for win32 only > > > sendmail_from = [EMAIL PROTECTED] ;for win32 only > > > ;sendmail_path = ;for unix only, > > > may supply arguments as well (default is sendmail -t) > > > > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > --- > > [This E-mail scanned for viruses by gonefishingguideservice.com] > > > > > > --- > [This E-mail scanned for viruses by gonefishingguideservice.com] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() problems...
Anthony, Do you have an SMTP server on your Win98 localhost? Recommend you change the PHP.INI SMTP= to say the same as your email package's server definitions. =dn > I'm using MS Win98 and Apache and getting the following after submitting the > mail form: > .. > Warning: Failed to Connect in c:\program files\apache > group\apache\htdocs\send_simpleform.php on line 14 > > > The html and php scripts follow along with my php.ini settings. > > Any help would be appreciated. > > Thank you. > Tony Ritter > > The following e-mail has been sent: > Your Name: > Linda > > Your E-Mail Address: > [EMAIL PROTECTED] > > Message: > Test > . > > > //this is the html form > > > > Simple Feedback Form > > > > > > > Your Name: > > > Your E-Mail Address: > > > Message: > > > > > > > > > .. > //this is the php script > if (($sender_name == "") && ($sender_email == "") && ($message == "")) { > header("Location: http://localhost/simple_form.html";); > exit; > } > $msg = "E-MAIL SENT FROM WWW SITE\n"; > $msg .= "Sender's Name:$sender_name\n"; > $msg .= "Sender's E-Mail: $sender_email\n"; > $msg .= "Message: $message\n\n"; > $to = "[EMAIL PROTECTED]"; > $subject = "Web Site Feedback"; > $mailheaders = "From: My Web Site <> \n"; > $mailheaders .= "Reply-To: $sender_email\n\n"; > mail($to, $subject, $msg, $mailheaders); > ?> > > > Simple Feedback Form Sent > > > The following e-mail has been sent: > Your Name: > > Your E-Mail Address: > > Message: > > > > > My php.ini settings are: > > [mail function] > SMTP = localhost ;for win32 only > sendmail_from = [EMAIL PROTECTED] ;for win32 only > ;sendmail_path = ;for unix only, > may supply arguments as well (default is sendmail -t) > > > > > > -- > 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] mail function() with MS
Hi Anthony > Qusetion: 1: > What would happen if I changed the php.ini settings to: > SMTP=mail.yourisp.com > sendmail_from=MyAddress@MyDomain > as opposed to: > >SMTP=smtp.ISPs.domain =as long as the SMTP server is accessible and you have access rights, then it can be anyone's/anywhere... > > When you use PHP provided by a service, you will need to establish what > they > > have set up as SMTP server, and if it is not acceptable to you (for > whatever > > reason that might be) work out how to override it. > I'm not sure why I would not think it is not "acceptable". Please advise. =Some web-hosts only have the one PHP.INI. That means you would have to use what they define as SMTP server. I don't know (a) what the host may define, (b) what you will find acceptable... ie it may or may not result in an issue/be relevant to you. > Also...let's say I'm developing another site with a mail form box using > Win98 and Apache > Do I then have to reconfigure the php.ini files back to localhost from: > SMTP=mail.yourisp.com =each PHP/web server has its own PHP.INI file. Thus each defines its own (default) SMTP server. =it may not be necessary to move SMTP servers: remember that your FROM: address can be [EMAIL PROTECTED] even though the PHP-defined SMTP server is smtp.isp.domain. =if you use a good script/class, each application you build can define its own SMTP parameters and have its own domain/From address, etc. > Thank you. =a pleasure. =did I understand the intent of the question correctly? =dn > TR > > > > I use a script/class from PHPguru.org, and I can't say for sure that it > even > > looks at the PHP.INI settings because I set them directly/again within the > > mail function's code. Highly recommended! > > > > > > --- > [This E-mail scanned for viruses by gonefishingguideservice.com] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail function() with MS
Hi Anthony, > I'm using MS Win 98 and my ISP has PHP installed on a MS server. > I'd like to display a HTML form box on my site for users to type in a > message utilizing the PHP mail() function. > > I've tested this using Apache on my drive with a html form and a php script > to receive the data and it works fine - but when the site goes live it will > be hosted with an ISP with a MS server - not Apache. > Is it possible to utilize the PHP mail function under these conditions? > > I was led to believe that I could change the configurations in my php.ini > file from: > SMTP: localhost > to > SMTP: mail.yourisp.com I use Win2000Prof with Apache, and have Win2000Svr with IIS. In each case I use a separate and external SMTP server. This is the relevant section of PHP.INI: [mail function] ; For Win32 only. SMTP=smtp.ISPs.domain ; For Win32 only. sendmail_from=MyAddress@MyDomain When you use PHP provided by a service, you will need to establish what they have set up as SMTP server, and if it is not acceptable to you (for whatever reason that might be) work out how to override it. I use a script/class from PHPguru.org, and I can't say for sure that it even looks at the PHP.INI settings because I set them directly/again within the mail function's code. Highly recommended! Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] Checking for Overlapping Dates
Thomas (and list), The solution, as previously posted, is flawed/incomplete - mea culpa. Excuse: I was interrupted three times from typing the word SELECT until pressing Send, and then rushing to get on to the next call on my time... >WHERE bstart < afinish > OR bfinish > astart; Check back with the diagram and you will see that a bstart clause needs to also check that bstart >= astart to trigger rejection - if the leave starts AND finishes before the 'replacement's' leave, then all is well - similarly for second clause. Now, if you prefer to inform a positive response, eg "leave may be granted", then when you turn things around, pay special attention to the relationship and changing ORs and ANDs. Better if we change the whole logic around and say "when can we grant annual leave?" because then the answer becomes: if bfinish < astart or fstart > afinish. This has the additional advantage of 'scaling', if the employee has more than one potential 'replacement'! In all approaches beware the special case: that the 'replacement' has no outstanding request for leave! Again apologies, =dn > > SELECT * from $DB_TBLName WHERE > > (Trim(WorkerEmail)='$userReplacementEmail') > > AND AND OR OR OR OR OR > > This is all a bit complicated, and a simple boy like me gets lost too > easily. KISS principle: Keep it simple... > > You have two employees: > A, so named because he Already has Annual leave Approved, and > B, so named because he is Begging to Be allowed to Break out. > > Let's imagine we're playing with a wall-chart/wall-planner to assess > requests prior to granting approval. So we mark off which days A will be > away and then view which days B would like to go against existing requests. > > Month A Month BMonth C Month etc > A <---> > B <> > > Assuming the email/fonts haven't mucked-up my sketch, you can see that B's > request should be denied, because A has already booked the time-out. > > Now let's use the diagram to build an algorithm. How many ways are there > that A and B could overlap? (hint: four) Not overlap? (hint: two) Which is > the easiest to implement in code? > > Now you can ask, which language should I code in? Answer: stay as close to > the source as possible, ie use SQL (or in this case pseudo-SQL(!)). > > SELECT a AS Colleague, CONCAT( astart - afinish ) AS PermissionDenied >FROM tbl >WHERE bstart < afinish > OR bfinish > astart; > > Before this will work, you will need to add another WHERE clause to > establish who is the employee's "replacement". The above lists a reason for > rejection - you can reverse the logic, at your peril. > > Trust this assists, > =dn > > PS The complicating question I wanted to ask from the word "go" is: what if > one person can have more than one other employee act as his/her > "replacement"? > > > > > > Background: > > > > > > I've created a vacation-request application for our company's intranet. > > When an employee requests a vacation, he has to list the name of another > > employee who will 'fill in' for him while he is gone. > > > > Before a vacation request can be saved in MySQL, I need to check to make > > sure that the person listed as the employee's replacement during this time > > has not already requested a vacation during the same time period...to > > check to be sure that the two vacation periods do not overlap. > > > > Date Ranges: > > > > > > I have fields saved in MySQL called unixStartDate & unixEndDate that are > > unix timestamps for the first day of the employee's vacation and the last > > day of the emplosyee's vacation. > > > > I have tried to do a check using purely SQL, but this doesn't account for > > all possibilities of overlapping dates: > > > > (unixStartDate is the unix timestamp for the replacement, whereas the PHP > > var $unixStartDate is the unix timestamp for the employee who wants to > > post a new vacation request) > > > > $checkSQL = "SELECT * from $DB_TBLName WHERE > > (Trim(WorkerEmail)='$userReplacementEmail') > > AND (Status < 40) > > AND > > ( > > ( > > ($unixStartDate = unixStartDate) > > ) > > OR > > ( > > ($unixEndDate = unixEndDate) > > ) > > OR > > ( > > ($unixStartDate = unixEndDate) > > ) > > OR > > ( > > ($unixEndDate = unixStartDate) > > ) > > OR > > ( > > (unixStartDate < $unixStartDate) && (unixEndDate > $unixEndDate) > > ) > > OR > > ( > > (unixStartDate > $unixStartDate) && (unixEndDate < $unixEndDate) > > ) > > ) > > "; > > > > So I think what I instead need to do is use PHP code instead of SQL to > > check for overlapping dates in the 2 date ranges I have. > > My two ranges would be like this: > > > > Replacement's Date Range: > > > > $unixStartDateReplacementVacation > > ...to... > > $unixEndDateReplacementVacation > > > > Employee's Date Range: > > > > $unixStartDateEmployeeVacation > > ...to.. > > $unixEndD
Re: [PHP] Checking for Overlapping Dates
Hi Thomas, > SELECT * from $DB_TBLName WHERE > (Trim(WorkerEmail)='$userReplacementEmail') > AND AND OR OR OR OR OR This is all a bit complicated, and a simple boy like me gets lost too easily. KISS principle: Keep it simple... You have two employees: A, so named because he Already has Annual leave Approved, and B, so named because he is Begging to Be allowed to Break out. Let's imagine we're playing with a wall-chart/wall-planner to assess requests prior to granting approval. So we mark off which days A will be away and then view which days B would like to go against existing requests. Month A Month BMonth C Month etc A <---> B <> Assuming the email/fonts haven't mucked-up my sketch, you can see that B's request should be denied, because A has already booked the time-out. Now let's use the diagram to build an algorithm. How many ways are there that A and B could overlap? (hint: four) Not overlap? (hint: two) Which is the easiest to implement in code? Now you can ask, which language should I code in? Answer: stay as close to the source as possible, ie use SQL (or in this case pseudo-SQL(!)). SELECT a AS Colleague, CONCAT( astart - afinish ) AS PermissionDenied FROM tbl WHERE bstart < afinish OR bfinish > astart; Before this will work, you will need to add another WHERE clause to establish who is the employee's "replacement". The above lists a reason for rejection - you can reverse the logic, at your peril. Trust this assists, =dn PS The complicating question I wanted to ask from the word "go" is: what if one person can have more than one other employee act as his/her "replacement"? > Background: > > > I've created a vacation-request application for our company's intranet. > When an employee requests a vacation, he has to list the name of another > employee who will 'fill in' for him while he is gone. > > Before a vacation request can be saved in MySQL, I need to check to make > sure that the person listed as the employee's replacement during this time > has not already requested a vacation during the same time period...to > check to be sure that the two vacation periods do not overlap. > > Date Ranges: > > > I have fields saved in MySQL called unixStartDate & unixEndDate that are > unix timestamps for the first day of the employee's vacation and the last > day of the emplosyee's vacation. > > I have tried to do a check using purely SQL, but this doesn't account for > all possibilities of overlapping dates: > > (unixStartDate is the unix timestamp for the replacement, whereas the PHP > var $unixStartDate is the unix timestamp for the employee who wants to > post a new vacation request) > > $checkSQL = "SELECT * from $DB_TBLName WHERE > (Trim(WorkerEmail)='$userReplacementEmail') > AND (Status < 40) > AND > ( > ( > ($unixStartDate = unixStartDate) > ) > OR > ( > ($unixEndDate = unixEndDate) > ) > OR > ( > ($unixStartDate = unixEndDate) > ) > OR > ( > ($unixEndDate = unixStartDate) > ) > OR > ( > (unixStartDate < $unixStartDate) && (unixEndDate > $unixEndDate) > ) > OR > ( > (unixStartDate > $unixStartDate) && (unixEndDate < $unixEndDate) > ) > ) > "; > > So I think what I instead need to do is use PHP code instead of SQL to > check for overlapping dates in the 2 date ranges I have. > My two ranges would be like this: > > Replacement's Date Range: > > $unixStartDateReplacementVacation > ...to... > $unixEndDateReplacementVacation > > Employee's Date Range: > > $unixStartDateEmployeeVacation > ...to.. > $unixEndDateEmployeeVacation > > > > > ...so i need to check that none of the dates occuring in the first date > range listed above appear in the second date range. > unfortunately, i have no basic idea of how i should go about doing > this...should i use arrays of dates, for-loops, or what? > thanks a whole lot in advance, > > Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] empty string parameters to backslashes?
Hey Andy, > I'm trying to track down a problem with someone else's > code. Our hosting service changed PHP versions on us > (up to 4.0.6), and everything broke. I think I have > tracked down at least part of the problem. We have a >... Ascertain differences by printing out a phpinfo() report for the new config and comparing with previous (obvious logic flaw noted!). It is as important for developers (as for installers) to read the ChangeLog (http://www.php.net/ChangeLog-4.php) to see what's new/different between versions. > But the output of the print statement looks like this: > funA START: file: productBrief, name: \, alt: \, size: 177\ > So where did the darned backslashes come from? Any ideas? Magic_quotes will do this. Check out manual: LXXIX. PHP Options&Information - the hosting service may have changed the setting on you. Follow links to learn how to SET and GET from within scripts. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expresion Work on IP address
Dev, Nice work! Thanks for implementing the book's algorithm/proving it in PHP-PCRE, and I do like your extension into an internal/external function. I've not implemented your code (bookmarked for later) but some initial comments: - don't forget some of the other 'funnies' in the IP addressing scheme, most notably 127.0.0.1 = localhost (which is also an 'internal' address) - I'd need to read/remind myself of others... - in the $parts[0]>=255 type of construct, remember that the > is superfluous - or the RegEx is overly specific (hence the discussion point earlier) - also the $parts[0] is a string, so "255" will be (marginally) faster - similarly you could make $ip_state="0"; into a boolean expression (and function return value) which might enable the function call to read more smoothly - regardless, $ip_state is currently sometimes treated as a string and once as an integer. - I don't know your IP allocations but in net_check() shouldn't all the if() logical ops be ANDs? Any thoughts of extending it to work with IPng addresses (or whatever they're calling it these days)? Great stuff, keep it coming! (and when you've finished perhaps you could submit it to one of the script libraries/improve on what they might already have?) =dn > Well after reading John'ss and DL Neil's replys i came up with 2 functions. > The first is to check to see if the entry is a valid IP address and the > Next is to determine if it is a Private Network IP or not!. > > You can see this in action at: > http://www.my-tangled-web.net/codebank/code/ip_check.php > and the sorce for that page is at: > http://www.my-tangled-web.net/codebank/getsource.php?dir=&file=ip_check.php > > Please if you test it and find a problem let me know! > > Thanks > > > function ipcheck($ip_chk){ > $parts=explode(".",$ip_chk); > if (preg_match > ("/^([01]?\d\d?|2[0-4]\d|25[0-4])\.([01]?\d\d?|2[0-4]\d|25[0-4])\.([01]?\d\d ?|2[0-4]\d|25[0-4])\.([01]?\d\d?|2[0-4]\d|25[0-4])$/", > $ip_chk)) > { > if($parts[0]==0 || $parts[0]>=255 ||$parts[1]>=255 || > $parts[2]>=255 || $parts[3]>=255){ > $ip_state="0"; > } > elseif($parts[0]<255 && $parts[1]<255 && $parts[2]<255 && > $parts[3]<255){ > $ip_state="1"; > } > } > else { > $ip_state=0; > } > $this="that"; > return $ip_state; > } > > function net_check($ip_2_chk){ > $parts=explode(".",$ip_2_chk); > if($parts[0]==10){ > $network="internal"; > } > elseif($parts[0]==172 && $parts[1]>=16 || $parts[1]<=31){ > $network="internal"; > } > elseif($parts[0]==192 && $parts[1]==168){ > $network="internal"; > } > else { > $network="external"; > } > return $network; > }; > > At 07:47 PM 12/4/2002 +, DL Neil wrote: > >John, > > > > > I think it'd be hard to verify the range with a regex. ip2long and long2ip > > > do not validate. So, an option would be to write your own little function > > > that splits the $ip on the period, verifies there are 4 parts, then checks > > > that each part is between 1 and 255 inclusive. > > > > > >My other post on the subject notwithstanding, I agree. > > > >When I get time/when I get a round tuit, I'd like to do a performance test > >on the (short) IP RegEx against what you have outlined: > > > >explode against "." > >run resultant array through 0-255 validation function > >- and still have the semantic issues of 0.0.0.0, etc... > > > >Meantime, will sit here whistling and quietly muttering into my beard (and > >dreaming of tuits), > >=dn > > > > > >-- > >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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expresion Work on IP address
John, > I think it'd be hard to verify the range with a regex. ip2long and long2ip > do not validate. So, an option would be to write your own little function > that splits the $ip on the period, verifies there are 4 parts, then checks > that each part is between 1 and 255 inclusive. My other post on the subject notwithstanding, I agree. When I get time/when I get a round tuit, I'd like to do a performance test on the (short) IP RegEx against what you have outlined: explode against "." run resultant array through 0-255 validation function - and still have the semantic issues of 0.0.0.0, etc... Meantime, will sit here whistling and quietly muttering into my beard (and dreaming of tuits), =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expresion Work on IP address
Hello Dev, > Now I am continuing on with the same script and I need to check for valid > IP address form. > Currently I have: > > $ip="255.255.255.0"; > if (preg_match ("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/", $ip)) { > print "Good Ip"; > } else { > print "Bad Ip"; > } > > This does work kinda. It checks to see if the 4 sets of numbers are well > there and numbers. > The problem I am having is that it does not check to see if the IP is in a > proper range ie less than 255.255.255.255 > So you could enter 256.256.256.999 and it will say that it is a good IP. > > Any clue how I would change it to check for that I'm reading my way through Friedl's, "Mastering Regular Expressions", O'Reilly, 2002. This is discussed in pp187-9, but I haven't had a chance to 'play' with it yet (!) and indeed he comments that it is one of those topics that you can attempt to refine and refine, but may be equally well off by sticking with what you have (surround the individual octet values with parentheses and then perform the semantic checking in PHP - as you discuss). What he comes up with observes the shorter range of digits for the first two digit positions of a (possible) three digit octet expression (in decimal), eg the first digit is either 0, 1, or 2 or not present at all. So if the first digit is a 1, then the next digits can be anything. If the first digit is a 0 or a space/non-existent then... However if the first digit is a 2, then the next digit may not exceed 5 [0-5]. If it is 5 then the last digit is similarly constrained, but if the second digit is less than 5, the third can be any digit. NB the 0.0.0.0 and 255.255.255.255 issues remain Thus the main component (handling each octet) is the basic code: ([01]?\d\d?|2[0-4]\d|25[0-5])\. which in English comes out as something like: a zero and a one may be present and followed by a digit and possibly another digit, or a two will be present, followed by a digit in the range 0 through 4, followed by another digit, or a two and a five will be present followed by a digit in the range 0 through 5, and then a dot/separator. This turns the whole shebang into: ^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2 [0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$ I'm sorry, but that's going to be diabolic to read after the email has had at it. The ^ and $, begin/end are necessary to ensure that there aren't over-running digits afore or aft of the IP addr. NB this is NOT tested (by me). I'm not sure if this code (the options in particular), as it is written, can be pasted straight into PHP's version of PCRE. YMMV! If you try it, please send feedback, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] My first post
Hi Victor, Welcome to the wonderful world of PHP! > I'm new in PHP. Could you point me where can i download a sample script > about how can i paginate some results? PHP essentially exists to output HTML. You cannot paginate in HTML (although there is some fancy CSS that could be employed). Sorry, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date
Hi Shaun, > please could someone tell me how i can return a month in text from an int ie > getMonth(12) > returns Decmber. Is this possible? No. If you want to stick with this, write your own function to look up a text array. If the "12" is part of more data coming in from a form or db (for example), then give us the wider picture and a 'built-in' solution may become possible. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Triggering a PHP Script
Ryan, > My Problem: > I've got a PHP script (running on Apache) that can take several hours > to complete. The script sends out a newsletter to those who have > requested it. When calling this script from a web browser, the browser > hangs until the script has fully executed. If the user hits "Stop" > while the script is running, it will terminate the script. > > My Questions: > What is the best way to trigger this script? Is there a way to do it > without using a CGI script? I am basically wondering if there is a way > to create a "trigger this php page" script that will run the script on > Apache and not hang the browser. Also, are there any problems calling > MySQL from a PHP CGI script? First: trust that you are only sending to opted-in clients!? (we're kind of sensitive about spammers around here!) The manual is your friend: Chapter 23. Using PHP from the command line. Add code to prevent PHP from timing-out (see another current thread) and that takes care of your program. It will now run, outside the browser, in the background, and you/your user can carry on using the browser... As far as "trigger" goes, you can type the command into the command line, or run some sort of 'job', or set it up to run off a scheduler, eg CRON or AT/Scheduled Tasks. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Test links?
Rob/Beth, The code should also consider: 1 updating the db if the link is 'valid', ie if previously it had been 'down'! 2 putting an @ to prevent any errors causing a hard-stop at the fopen line 3 that the url/database must contain protocol information, ie http://www.nytimes.com not www.nytimes.com. Thanks for the discussion, =dn > Rob Packer wrote: > > >Okay, I'm confused... file, fopen, and fsockopen seem to say not found on > >alot valid URLs... does this look to be correct usage? > >$url = $row[0]; // just get the url from the db > >$fp = implode ('', file ($url)); > > if (!$fp) {echo "Unable to access file"; } > > else { fclose($fp); echo "The link is working!"; } > > > >It seems I always get this warning... > > > >Warning: Supplied argument is not a valid File-Handle resource in > >/web/home/nrc.net/www/robert/links4.php on line 11 > > > >If someone can tell me what I'm doing wrong, I'd appreciate it. > > > >Thanks, > >Robert > > > > > > > > > > > When fopen successfully opens a file it populates an array > $http_response_header, which you can examine to see if the link works or > not - I don't believe you can actually get the file itself, but since > that's not what we're after that's not a problem! > > Having said that, fopen produces a very annoying error if it doesn't > find the page, but I found the following works: > > > $SQL = "SELECT linkurl, linkID FROM links"; > $result = mysql_query($SQL); > > while($linkdata = mysql_fetch_array($result)){ > > $fp = fopen($linkdata['linkurl'],"r"); > if($fp) > { > echo "".$linkdata['linkurl']." is still valid."; > > }else{ > > echo "".$linkdata['linkurl']." is invalid. Updating > database... "; > > $SQL = "UPDATE links SET status = 0 WHERE linkID = > '".$linkdata['linkID']."'"; > $result2 = mysql_query($SQL); > if($result2) > { > echo "Database updated"; > } > } > > } > ?> > > Rather than deleting the link, it's probably better to set a flag to > show it was invalid last time you checked, but check it again next time. > Or you could keep a count of the number of failed attempts, and delete > if it goes beyond 3 or so. > > Not sure how to supress the warning message that PHP automatically does > when you haven't got a valid URL though. > > Hope this works for you! > > Beth Gore > -- > http://bethanoia.dyndns.org > > > -- > 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] Test links?
Beth, > When fopen successfully opens a file it populates an array > $http_response_header, which you can examine to see if the link works or > not - I don't believe you can actually get the file itself, but since > that's not what we're after that's not a problem! I noticed this reference to "$http_response_header" and straightaway quizzed the manual, only to find that the only references to it (eg file open) lead nowhere. Have gone through a few other pages, looking to see if I might happen upon some detail, but failed. Sadly you don't refer to it in the code snippet provided (below). Any code I've attempted blindly has failed/reported errors. Please point me in the right direction (otherwise I guess it'll be time to download the new v4.3.0-RC and risk the bleeding edge - which according to the manual does something different anyway...) =dn > Having said that, fopen produces a very annoying error if it doesn't > find the page, but I found the following works: > > > $SQL = "SELECT linkurl, linkID FROM links"; > $result = mysql_query($SQL); > > while($linkdata = mysql_fetch_array($result)){ > > $fp = fopen($linkdata['linkurl'],"r"); > if($fp) > { > echo "".$linkdata['linkurl']." is still valid."; > > }else{ > > echo "".$linkdata['linkurl']." is invalid. Updating > database... "; > > $SQL = "UPDATE links SET status = 0 WHERE linkID = > '".$linkdata['linkID']."'"; > $result2 = mysql_query($SQL); > if($result2) > { > echo "Database updated"; > } > } > > } > ?> > > Rather than deleting the link, it's probably better to set a flag to > show it was invalid last time you checked, but check it again next time. > Or you could keep a count of the number of failed attempts, and delete > if it goes beyond 3 or so. > > Not sure how to supress the warning message that PHP automatically does > when you haven't got a valid URL though. > > Hope this works for you! > > Beth Gore > -- > http://bethanoia.dyndns.org > > > -- > 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] How to give parameters to a console php-script?
Martin, Ah yes, the famous 'read the upgrade notes - gotcha'! Well done, you figured it out... =dn > ll I found a > register_argc_argv = On > > in my php.ini, which should work then. But I also found, that I have to use > > print "Ok: ".$_SERVER["argv"][1]; > > instead of > print "Ok: ".$argv[1]; > > Martin > > > > -- > 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] How to give parameters to a console php-script?
Hello Martin, > I start a console app with > > php myscript.php4 (just prints "ok"). > > How can I give parameters to it? I tried: > php myscript.php4 myparameter > php myscript.php4?myparameter > php myscript.php4?param=myparameter > > But always php just returns without doing nothing (not even giving an > error or printing "Ok"!) I'm using PHP 4.2.3. on Windows2000). I'm using the same version/platform and things work fine (for me). Manual: Chapter 23. Using PHP from the command line You are correct the first time. What do argv and argc tell you? Is the php.ini file set up so that these variables are shown/valid? Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting email bounces sent by the mail function?
Hello Ade, > Is it possible to detect with PHP whether an email sent using the PHP > 'mail' function has bounced back or has not been delivered? > > I currently all ready check the email address using the 'ereg' function > before the mail function is called, but this only checks the format is > valid beforehand. Yes, and No! If you use the ReturnPath header SOME/most email servers will bounce msgs that they can't deliver to an actual mailbox back to you (others drop such msgs onto an Admin somewhere, lose them in the ether (the msgs not the Admins...) etc, etc). Accordingly, use a distinct address for this/email filing rules. Opt-in email schemes which send a welcome/confirm email to new customers do so for this reason - the only way to verify an email address is to use it (and get some feedback from the addressee). Of course, once you have 'located' a new user, you still have to cope with those who close email accounts without advising you... It's a wonderful world! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IPs comparing
Hi JesĂºs, > I have several subnets in my network and want to show different webs > depending on the subnet the user was. > > I know how to get the IP but not how to compare two IPs numeracally, I mean: > > > If ((USER-IP > 192.168.0.1) && (USER-IP < 192.168.0.255)) > Else if ((USER-IP > 192.168.1.1) && (USER-IP < 192.168.1.255)) > ... > > What do you suggest me? I suggest treating them as strings, and use (IF) equality/switch statements to deliver the appropriate web... Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql report builder
Hi Mike; > sorry for posting this mysql question again. im searching for a report > builder for mysql specifically for creating reports for > invoice/receipt..etc. > just like crystal reports and oracle report builder. or is there any > suggestion to do it in PHP . On my travels (FWIW) I have seen nothing as sophisticated as Crystal/Oracle*Reports (and certainly not open/free) - however I have been v.pleased not to be asked to provide such (well I was once, but he was such an Excel 'expert', I gave him the data and let him while away many 'happy' hours...) You have reminded me that before I was dragged away onto another project/product set, I had started to play with JaneBuilder (www.seejanecode.com/). Which is really simple but seems to do a heap of basic 'grunt work' of turning table schema into display/data-entry forms, etc. May be a start!? Please let us know your findings, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Invalid Charactors in a string.
Gidday Philip, Full answer: http://www.oreilly.com/catalog/regex/ Short answer: PHPBuilder etc have articles introducing the use of RegExes (Regular Expressions) for this sort of thing. (but please not the Arthurian "how do I validate an email address"...) Regards, =dn > Where should i start, tips wanted. > > I would like to check a username string for valid charactors before the name > is processed. > > Someone point me in the right direction please > > --- > Philip J. Newman. > Head Developer. > PhilipNZ.com New Zealand Ltd. > http://www.philipnz.com/ > [EMAIL PROTECTED] > > Mob: +64 (25) 6144012. > Tele: +64 (9) 5769491. > > VitalKiwi Site: > Philip J. Newman > Internet Developer > http://www.newman.net.nz/ > [EMAIL PROTECTED] > > * > Friends are like Stars, > You can't always see them, > But you know they are there. > > * > > ICQ#: 20482482 > MSN ID: [EMAIL PROTECTED] > Yahoo: [EMAIL PROTECTED] > AIM: newmanpjkiwi > > > > -- > 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] Getting the script path of a commandline script
Ryan, > Anyone know how to get the script path (not the current working directory, > but the actual path of the executing script) of a commandline script? > > I've dug through the docs and can't find this anywhere. None of the > typical $_SERVER variables return the script path (although several of > them return the filename, hooray for redundancy). The docs say several > times that getcwd() will NOT return the path of the executing script, but > they don't mention how to get it. _SERVER["argv"] [ 0 ] gives the full path to the script (including the script's name and filetype) =dn PS if you want to know more, run the standard PHPINFO() through the command line, piping to an output.HTML file, then drop that into your browser! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If statement w/ multiple conditions
Ed, Assuming there will be a response from the db-tbl, here is another choice: if ( $lineone . $linetwo . $linethree . $linefour > "" ) { //show it to the user and ask if they want to change it } else { //prompt for information } Do you mean that the db-tbl will have a row of data even if the four fields are empty, or if there is no data (in those fields) will that imply that there is no row (and thus different code needed)? =dn > All four must be an empty string. I will be pulling the values from a > MySQL database. If these fields are empty I'll be prompting for > information. If any one of them contain anything I'll be showing it to > the user and asking if they want to change it. > > Thanks, > > Ed > > > On Tue, 26 Nov 2002, Ernest E Vogelsinger wrote: > > > At 13:50 26.11.2002, [EMAIL PROTECTED] said: > > [snip] > > > I'll be trying to use a routine that checks 4 seperate variables for > > >content and need to know the easiest method to do so. The function works > > >on 2 conditions; either all the variables are empty and I do something or > > >I do something else. > > > > > >$lineone > > >$linetwo > > >$linethree > > >$linefour > > > > > > Would you use > > > > > >if ($lineone && $linetwo && $linethree && $linefour = "") > > [snip] > > > > Your expression yields true if 1-3 are not-empty AND four is an empty > > string. Not sure if that's what you want. > > > > All empty: > > !($lineone || $linetwo || $linethree || $linefour) > > --or-- > > !$lineone && !$linetwo && !$linethree && !$linefour > > > > All set: > > $lineone && $linetwo && $linethree && $linefour > > > > > > -- > >>O Ernest E. Vogelsinger > >(\)ICQ #13394035 > > ^ http://www.vogelsinger.at/ > > > > > > > > -- > > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array manipulations
Mattia, > Can anyone suggest an ELEGANT way to find out if an array is made of empty > strings or not? > example > $a = Array( '' , '' , '' ); //ok > $b = Array( '' , '' , 'error' ); // not ok > $c = Array( 'error' , '' , 'error' ); // not ok implode() then check for nullstring/count characters. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does //commenting reduce performance?
Jason, ad infinitum, ad nauseum However it was your recent post that (sig file) quoted the Freudian: ontogency recapitulates phylogeny We should make them become more like us - even if we kill them in the process! =dn > On Sunday 24 November 2002 22:58, DL Neil wrote: > > Neatly done Ernest! > > Also in showing how these questions are best answered with five minutes on > > the PC, than a msg to the list... > > ... until someone else comes along and asks a similar question and you have to > show them again how it's best answered with five minutes on the PC, than a > msg to the list ... ad infinitum > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > Who's on first? > */ > > > -- > 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] Setting values of php.ini file at runtime
Justin, Neat! Don't limit thoughts to PHP when can solve it in Apache - thank you, =dn > a .htaccess file in the directory you want RG OFF (ie /wiki/) should do the > trick: > > > php_flag register_globals on > > > This seems to work for me... > > > on 25/11/02 10:37 PM, DL Neil ([EMAIL PROTECTED]) wrote: > > > Excuse me breaking in...somewhat similar problem: > > > > Have set up a client recently, preaching security persuaded them into > > updating so that could run Register_Globals=Off. Now they want to install a > > 'wiki' which requires (to my horror) Register_Globals=On. > > > > Short of two Apache/PHP servers, what is a logical way to structure things > > so that the 'wiki' runs 'insecure' but other/'my' PHP work runs more > > securely? > > > > Please advise, > > =dn > > > > > >> You cannot do it inside a script as the register_globals magic happens > >> before the script starts executing, so toggling the setting at runtime is > >> too late. > >> > >> -Rasmus > >> > >> On Mon, 25 Nov 2002, Tariq Murtaza wrote: > >> > >>> Dear All, > >>> > >>> I am wondering if anyone shed some light. > >>> i am thinking of setting value for php.ini variables like > >>> register_globals = ON/OFF at runtime (within our php script). > >>> Is there any function built-in in php?, or can we do it ourselves. > >>> > >>> Looking forward, > >>> Thanks > >>> > >>> Tariq > >>> > >>> > >>> > >>> -- > >>> 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 > >> > >> > > > > Justin French > > http://Indent.com.au > Web Development & > Graphic Design > > > > -- > 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] Setting values of php.ini file at runtime
Excuse me breaking in...somewhat similar problem: Have set up a client recently, preaching security persuaded them into updating so that could run Register_Globals=Off. Now they want to install a 'wiki' which requires (to my horror) Register_Globals=On. Short of two Apache/PHP servers, what is a logical way to structure things so that the 'wiki' runs 'insecure' but other/'my' PHP work runs more securely? Please advise, =dn > You cannot do it inside a script as the register_globals magic happens > before the script starts executing, so toggling the setting at runtime is > too late. > > -Rasmus > > On Mon, 25 Nov 2002, Tariq Murtaza wrote: > > > Dear All, > > > > I am wondering if anyone shed some light. > > i am thinking of setting value for php.ini variables like > > register_globals = ON/OFF at runtime (within our php script). > > Is there any function built-in in php?, or can we do it ourselves. > > > > Looking forward, > > Thanks > > > > Tariq > > > > > > > > -- > > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] security of stand alone script
Hi gamin, >Running Red Hat 7.2, PHP 4.0.6. Is there any way of knowing if a certain > PHP script was run from the command line, shell script or through the > webserver (Apache). May be i could check the user calling the script and > find out but how would i do that ? There is a difference in the way argc and argv are managed - see manual. Also (do two phpinfo() runs to check - one under Apache and one from the command line) depending upon the web server (Apache in our cases) there are whole sections of the 'standard output' that do not have relevance from the command line (because there is no web server!), eg SERVER_SOFTWARE and SERVER_SIGNATURE. Should you figure out something better than this, please let me know too! Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does //commenting reduce performance?
Ernest, > Some time ago I've made myself a framework for such tests and have run it > against a commented loop. This test was run on a dual PIII/1000 Dell server. > > $hpr = _fwx_profile_start('Loop with end-of-line comment', true); > for ($i = 0; $i < 100; ++$i) { > $a += 1;// this is an end-of-line comment > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > $hpr = _fwx_profile_start('Loop with inline comment', true); > for ($i = 0; $i < 100; ++$i) { > /* this is an inline comment */ $a += 1; > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > $hpr = _fwx_profile_start('Loop without comment', true); > for ($i = 0; $i < 100; ++$i) { > $a += 1; > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > Conclusio: I didn't find any measurable difference in these loops, be it an > end-of-line comment, an inline comment, or no comment. =Apologies: I hit 'Send' on the preceding msg, even before signing off... Duh! =I have a similar test bench/frame, but which only puts out microtime differences. My personal/dev PC is an Armada portable with 266MHz processor and so is considerably more modest than your own beastie. =I find that because the wee beastie is running PHP, Apache server, MySQL server, etc, etc; that multiple runs of the same code can yield considerable differences in execution time - see also warnings in manual, eg 'caching'. Accordingly I run six cycles and record the last three: =Herewith: End of line comment: 4.3118, 4.415713, 4.342078 Inline comment: 4.331843, 4.403446, 4.339082 Loop without comment: 4.415728, 4.399776, 4.420114 =however a quick analysis shows that the fastest-slowest differences are: .104, .072, and .021 (secs, resp) =the differences between test types run to: slow end: .012, and .017 fast end: .020 and .068 =In other words, apart from the first set of tests, any and all differences are insignificant/disappear into 'noise'. However, if the "Loop without comment" results make sense to you - you're a better man than I, Gunga Din! =Concur completely with your own analysis, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does //commenting reduce performance?
Neatly done Ernest! Also in showing how these questions are best answered with five minutes on the PC, than a msg to the list... > At 12:58 24.11.2002, DL Neil said: > [snip] > >Why don't you run a microtime testbench to time a commented and an > >uncommented loop, settle your mind, and report back with REAL information!? > [snip] > > Some time ago I've made myself a framework for such tests and have run it > against a commented loop. This test was run on a dual PIII/1000 Dell server. > > $hpr = _fwx_profile_start('Loop with end-of-line comment', true); > for ($i = 0; $i < 100; ++$i) { > $a += 1;// this is an end-of-line comment > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > $hpr = _fwx_profile_start('Loop with inline comment', true); > for ($i = 0; $i < 100; ++$i) { > /* this is an inline comment */ $a += 1; > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > $hpr = _fwx_profile_start('Loop without comment', true); > for ($i = 0; $i < 100; ++$i) { > $a += 1; > } > _fwx_profile_end($hpr, $i); > Average time per loop: 0.059 msec > > Conclusio: I didn't find any measurable difference in these loops, be it an > end-of-line comment, an inline comment, or no comment. > > > -- >>O Ernest E. Vogelsinger >(\)ICQ #13394035 > ^ http://www.vogelsinger.at/ > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] does //commenting reduce performance?
Adam, > I have always had the opinion that the more comments you put into php > scripts, the slower they will run because there is more data to be read... > Can someone tell me if there is any truth in this or whether commenting has > absolutely 'no' impact on the performance of a script? An answer proposed that there was little impact, but then suggested comments not be used within loops (one presumes from this, the concern is that even a little impact can mount up when repeated many times). Why don't you run a microtime testbench to time a commented and an uncommented loop, settle your mind, and report back with REAL information!? Computer programming is the embodiment of 'write once, run many' manta. Comments are no use at all during execution, but should be intended to be of considerable assistance during the writing/maintaining phases. Never give anyone an excuse for not writing (meaningful) comments - enough energy already goes into creative excuses for that - and you may be the next to suffer from some predecessor's arrogance! There are routines available which take in a developer's script and output a comment-less, stripped-down for maximum slipstream, dense code, version - ready for execution. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Help with Date
Rodrigo, Is there a way to convert a date " 20/11/2002 " to a Float number in PHP, since the date starts in 30/12/1899, just like the delphi treats the dates =Check out UNIX timestamps (but watch the valid date range), =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie: PHP/MySQL (SELECT)
> On Thursday 21 November 2002 03:53, Mr. BuNgL3 wrote: > > Hi... > > I'm with a little sintax problem... > > The question is that i have two search fields (titulotxt and cdstxt) and i > > want to create an mysql condition... i trying: > > > > $sql1=($titulotxt) ? "titulo like '%".$titulotxt."%'":""; > > $sql2=($cdstxt) ? "cds like '$cdstxt'":""; > > $sql="SELECT * FROM divx WHERE" .$sql1 " && " .$sql2 " ORDER BY titulo"; > > > > but he's giving me a sintax error on the 3 line... Can anyone > > teach me how i must do to validate the mysql condition and make it work? > > Try: > > $sql="SELECT * FROM divx WHERE" .$sql1. " && " .$sql2. " ORDER BY titulo"; and add a space after the WHERE. Also consider the positioning of the single quotes (') and double-quotes (") in the $sql1 assignment statement - they must be nested. Finally, consider echoing sql1, $sql2, and $sql to be able to see with your own eyes! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is wrong with this expression?
JohnMeyer > if (is_uploaded_file($_FILES["imagefile"]["tmp_name"]) && > ($_FILES["imagefile"]["type"] != "image/jpeg" && > $_FILES["imagefile"]["type"] != "image/gif" && $_FILES["imagefile"]["type"] > != "image/jpg" && $_FILES["imagefile"]["type"] != "image/png")) > > I'm trying to weed out everything that isn't a .jpg, .gif, or .png. What's > wrong with this? =when you have a complex question, simplify! =It would be called the KISS principle if you were better looking! =It doesn't seem to be bothering you, so let's assume that the is_uploaded section works. =First let's plug in an imagefile-type of .TIF TIF != "image/jpeg" is true TIF != "image/gif" is true TIF != "image/jpg" is true TIF != "image/png" is true =So true AND true AND true AND true is true, and presumably you will "weed out" that file***. But... =next let's plug in an imagefile-type of .GIF TIF != "image/jpeg" is true TIF != "image/gif" is false TIF != "image/jpg" is true TIF != "image/png" is true =So true AND false AND true AND true is false, and presumably you will "weed in" that file***. But... =Let's come back to that first phrase that looked so good: is_uploaded_file($_FILES["imagefile"]["tmp_name"]) =(***with such limited visibility as you have afforded us - an incomplete PHP statement -> cries of "unfair" are heard in the land!) It seems that if this is an uploaded file the logic will result in true, but if it is not, false. =Now add that to the above: our .TIF resulted in true so an uploaded file that is in .TIF format will be weeded out. But... =our .GIF resulted in false so regardless of whether we have an uploaded file or not, the result of the ANDs must be false! In other words, a JP(e)G, GIF, or .PNG file will be treated in the same way as a non-uploaded file!? Should the is_uploaded_file() question be separated from the question about the (un)acceptable types of file? =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browsing directory
Helen, > I would like to create a web page which allow people to browse the directory structure and the files listed in every directory. If you have experience about that, could you kindly give me some advice or references? Thanks in advance. =To this simple boy it seems like a strange, even a potentially insecure sort of thing to do, but ... =Suggest you don't try to implement in PHP. Use your web server, eg Apache, and allow it to display the filesystem if no index.htm or default.htm web page is available. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] BBC article: Intellectual Property
Open source campaigners and 'evangelists' may be interested in BBC coverage of a report by the Commission on Intellectual Property Rights (CIPR): http://news.bbc.co.uk/1/hi/sci/tech/2253270.stm. It talks of medical, agricultural, industrial, and IT/educational disadvantages placed in front of the developing world by assumptions/philosophies within the IP (Intellectual Property) community. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP / Bulk Email
> Hi Guys / gals, > > I ran a test recently sending emails to a list of clients (1000 or so) > from a PHP / MySQL powered system. > When sending via Sendmail this was VERY slow, taking several minutes to > complete. > When I switched over to Qmail the whole process takes only 10 or 15 > seconds. > Seems it's the MTA that causes the biggest overhead in the equation... and > Qmail is so much nicer than Sendmail! IIRC it is also an area where the Windows implementation of PHP is superior (for a pleasant change) on a volume/performance basis (I read somewhere that this is because a stub SMTP service is included in the interface). Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ridding myself of HTML tags
Liam, If you were to stristr()/remove everything up to and including the tag, would that take care of things? =dn > I've got a lil problem with HTML tags. Here's the description. > > My site accepts HTML files by upload. A lot of these files are written in MS > Word and then saved as HTML files from that. MS Word likes to put a bunch of > garbage at the beginning of the file. Now, when users upload their HTML > files, my script goes and striptags all of the unnecessary junk in there > except it can't rid all this junk (HTML, XML, CSS, JavaScript) at the > beginning of the HTML file. Some of these tags span multiple lines, and my > script goes through line-by-line, so it won't identify these as tags. Is > there a simpler fashion? I don't need the junk about style sheeting and > stuff, because I have a style sheet that will take care of styling the files > the way they should be. I don't want the extra tags, even though they're > invisible to users when they web-view, because these are e-mailable files > (for HTML mail, it's fine; for text mail, I need to strip it down and that's > the problem). > > = > Just in case, I've included the HTML code below: > > > xmlns:w="urn:schemas-microsoft-com:office:word" > xmlns="http://www.w3.org/TR/REC-html40";> > > > > > > > > Test test test > > > > > > > > > > > > Test test class=SpellE>test > > class=SpellE>Fdjfkasdjfkla > > class=SpellE> style='mso-bidi-font-weight:normal'>Fdjkslafjdklaf > > Â > > class=SpellE>Fdasfdfasffasdfdaadfdfs > > class=SpellE>Dfsdfs > > Hi > > Â > > style='mso-tab-count:3'> class=SpellE>Jfdklas > > Â > > > > > > > > -- > 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] Resource ID??
John, This is the output: Resource id #15 or some other seemingly arbitrary Resource ID number? First of all what is a resource ID and second how do I get it to actually show what I am trying to get it to show! =When MySQL returns data to PHP, the information is put into a variable called a "resource" special data type. When you attempt to treat this as if it were a string data type, all that it 'reveals' is the ResouceID (as you have found). =Please return to the manual, re-read the MySQL_query entry, and then move on to the MySQL_fetch_... series of functions. These are designed to extract (most usually) a row of data at a time from the ResourceID/MySQL resultset and make it available to your PHP script - examples given in the annotated manual. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mail()....
Brian, Please be aware that many email clients will NOT read HTML. The human readers are then presented with raw HTML and get very <...?...> upset about it! (that's why list postings are not supposed to be in HTML/rich text format) Regards, =dn > It's a text-based newsletter... > > I have a solution i think... so it'll look the same... just need to verify > that it *should* be the same... > > inserting the contents in html, but within a ? > > 2'nd, using the following headers, sends it as an attachment it seems... > > $headers = "MIME-Version: 1.0\r\n"; > $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; > > TIA.. > > "Brian McGarvie" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Is there a way to set the font on a plaintext email? > > > > > > > > -- > 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] variable reference parameters
Timo, If you use func_num_args() to ascertain the number of arguments passed to the function and func_get_arg() to retrieve each argument in turn (from a list of unstated length), will that do the trick? Regards, =dn > I've created (with help from some code from the site) a function to make > strings or arrays mysql safe. It works just fine, assuming you pass your > variables by reference ( sqlSafe(&$var) ), but I get this error every time > it is used: > > [error] PHP Warning: Call-time pass-by-reference has been deprecated - > argument passed by value; If you would like to pass it by reference, modify > the declaration of [runtime function name](). If you would like to enable > call-time pass-by-reference, you can set allow_call_time_pass_reference to > true in your INI file. However, future versions may not support this any > longer. in file.php on line X > > I want the function to be able to accept as many variables as needed to make > them sqlsafe (10 is enough for now), and to remove that annoying error, I'd > also like to not need to pass them by reference. Is this possible?? and if > so, how?? I know it is possible to add the & before each function parameter, > but then I can't pass more or less variables than I put in the function > definition, cause you can't have default values for a reference parameter > (go figure), and it'll also complain if you give it too few variables. > > function sqlSafe( $a0, > $a1=NULL, > $a2=NULL, > $a3=NULL, > $a4=NULL, > $a5=NULL, > $a6=NULL, > $a7=NULL, > $a8=NULL, > $a9=NULL){ > if(func_num_args()>10) > echo "Too Many Args in sqlSafe"; > for($i=0;$i $name="a" . $i; > if(!isset($$name)) continue; > if(is_array($$name)){ >foreach($$name as $n => $v){ > if(is_array($v)) > sqlSafe(&${$name}[$n]); > elseif(isset($v)) > ${$name}[$n] = mysql_escape_string ($v); >} > }else >$$name = mysql_escape_string ($$name); > } > } > > > > -- > 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] How can I strip the code from HTML pages to extract the contents of a HTML page.
Carlos, I'm sorry, but am just leaving... If you check the PCRE RegEx pages of the annotated manual, there are contributed examples that will help in this situation (probably under preg_match_all() ) Regards, =dn > This may be an interesting challenge for someone or has it been done > before > > Can some one help me. > > I am looking for a laboursaving method of extracting the contents of a > web page (Text only) and dumping the rest of the html code. > > I need the contents to rework the pages and put the contents into flat > file database. Large but only two columns of data. Simple to work with > (no need for DB) - They are just alot of links on a links page. > > Scripts would be welcome. > > Ciao, Carlos > > > > > -- > 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] Apostrophe in preg_match?
Andre, > Thanks DL, =a pleasure > I've read that part of the manual. My original syntax was as you > suggested [^a-zA-Z-'], but the PostgreSQl query barfed on the apostrophe. =these are two quite separate things (1) and (4): 1 accept input ($_POST) 2 validate input 3 prepare input for storage 4 store the input data > The preg_match works, but the db refuses to accept the apostrophe. Reading > the postgresql docs, they suggest escaping the character, but since the > variable is contained in $_POST['ssname'] I don't know how to get the escaped > character inserted into this POST'd variable. > > After the validation check : > > if (!preg_match("^[a-zA-Z-/\'/]^", $_POST['ssname'])) die . . . . . > > the POST'd variable is transformed: > > $_POST['ssname'] = ucwords("{$_POST['ssname']}"); > $_SESSION['ssname'] = $_POST['ssname']; > $_SESSION['ssname'] = ucwords("{$_SESSION['ssname']}"); > > and then inserted into the db: > > "INSERT INTO sponsor (sid, sfname, ssname, . . . '{$_SESSION['ssname']}', . . > . . > > So, how would I get this escaped character into the db? > > Any further help would be greatly appreciated. I'm stumped on this one. > Perhaps, I'll have to exclude apostrophes, but there must be a way?? =with PHP there's usually a way... =throw 'escape database' (apostrophe will work too) at the PHP manual's search facility (the manual is really v.good!) and it will respond with a reference to ADDSLASHES(), which will do as you ask - there is also a reference to a PG function (I'm not a PostGres user so can't assess if that might hold some advantage in your situation). =hope that helps, =dn > On Wednesday 28 August 2002 06:16 am, DL Neil wrote: > > > I'm trying to get an apostrophe (and a dash, as well) to be > > > included in a preg_match expression, but I don't know how to escape the > > > characters. > > > > The manual discusses which characters need escaping and how to escape > > characters: http://www.php.net/manual/en/pcre.pattern.syntax.php > > > > > > > if (preg_match("^[!a-zA-Z-/\\\'/]^", $_POST['ssname'])) die > > > ("Numbers and special characters not allowed in 'Surname' > > > Click 'Back' on your browser to re-enter > > > information."); > > > > > > ?> > > > Any help will be greatly appreciated. > > > > Keep it simple: [^a-zA-Z-'] > > > > Regards, > > =dn > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Window/Page/Browser/Screen width
Hi Rick Check out list archives for last week (and the week before...) keyword: resolution. Also check out HTML, which will cheerfully slap text and graphics together an adapt to local peculiarities. Regards, =dn > I've seen similar questions in archives so sorry if I'm asking the same thing > again! > > Is it possible, using php, to get the screen, page, or window width? > > My aim would be to have a set of picture thumbnails, and give the html the best > number of columns depending on the size of the display. > > I'd rather not use java, because many people have it turned off (even though I > wouldn't be exploiting it!) > > Cheers, > --Rick > > __ > Do You Yahoo!? > Everything you'll ever need on one web page > from News and Sport to Email and Music Charts > http://uk.my.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] No Localhost with apache?
Hi Ryan, Anyway, I installed PHPTriad first but since the version of php is 4.0.0 I uninstalled it and installed SpaceServer...the problem I noticed with both was I could not get the default page from apache with http://localhost/ I have to use http://127.0.0.1 or it gives me a page not found errorAny idea why? I have tried using it with the port numbers of :80 and :8080 without any luck..I need it to display the pages using "localhost" as some programs are configured that way... =What does a ping localhost and/or 127.0.0.1 give you? =Please advise, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apostrophe in preg_match?
> I'm trying to get an apostrophe (and a dash, as well) to be > included in a preg_match expression, but I don't know how to escape the > characters. The manual discusses which characters need escaping and how to escape characters: http://www.php.net/manual/en/pcre.pattern.syntax.php > if (preg_match("^[!a-zA-Z-/\\\'/]^", $_POST['ssname'])) die > ("Numbers and special characters not allowed in 'Surname' > Click 'Back' on your browser to re-enter > information."); > > ?> > Any help will be greatly appreciated. Keep it simple: [^a-zA-Z-'] Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search in serialized string
Rodrigo, Yuk! No wonder I was having trouble visualising your problem... The serialised field cannot be meaningfully indexed (it's a waste of time if it is). That means that any search against a criteria involving a/the serialised field will require (the time to perform an) the examination of every row - so make it the last clause of a SELECT - WHERE process. Given that I would expect that you/users would want to search on such an important field, the db designer/implementer deserves to be first up against the wall... NB if a user issues a fairly open search, eg all programmers (on an IT staffing database) - and let's just say that such represents a 50% 'hit rate' against the total number of rows/people's data stored, then if the table is thousands of names long, such a search for English-Advanced will be very, very 'expensive'/slow! However, I think we can do it. Two possibilities: 1 it may be possible to use a RegEx to examine the serialised text field for "English" and "Advanced" in the correct sequence and proximity. 2 haul all of the rows that satisfy the other WHERE criteria into PHP, deserialise each field, and do the check there and then. The second will be more expensive in terms of RAM and possibly time, but offers a guaranteed result. The first is possibly faster and is more storage-efficient but will require some thought/clever coding. I assume you could manage the first. If you would like me to have a go at tackling the second for/with you, then please provide: a) a copy of the PHP code which serialises the data and stores it in the database, b) a copy of any relevant array/class definitions, c) the MySQL CREATE TABLE line for the TEXT field used, d) (if not evident from the above), a list of some of the more likely languages and the skill levels used within the data, e) (if possible) some sample data to play with/prove. Could be fun, (but it won't be pretty!) Regards, =dn > I mean double ouch!!! :-) > > well.. > > 1 no, it's a select for the language ( to skill level > > 1b no separator it's stored as array. The array generated by language[] and > skill[] are stored into another array, serialized and put into DB > > 2 yes. could be up to 5 > > 2b again, none. only the array structure > > the field is a text. > > > on 8/26/02 9:58 AM, DL Neil at [EMAIL PROTECTED] wrote: > > > Rodrigo, > > > > Inherited problems = ouch! > > > > Sorry I don't keep old list msgs, perhaps you mentioned this before: does > > the language skills field contain: > > 1 both the language and the skill-level, eg English - Advanced > > 1b what separator is used between the two words? > > 2 more than one language/skill-level where applicable, eg English - > > Advanced, German - Intro. > > 2b what separator is used between language entries? > > > > What is the database field description in the table schema? > > > > Please advise, > > =dn > > > > > > > >> well, I my opinion is not the way to work, but like I said the work was > > done > >> by other guy, and now I have the problem to solve. So i back to old > > question > >> :-) > >> How can I search with some precision in a serialized string? > >> > >> > >> > >> on 8/24/02 12:13 PM, DL Neil at [EMAIL PROTECTED] wrote: > >> > >>> Rodrigo, > >>> > >>> Then the question to be asked is: is serialize()ing this data good > >>> design/technique, or is there a better way? > >>> > >>> Regards, > >>> =dn > >>> > >>> > >> > >> > >> -- > >> 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search in serialized string
Rodrigo, Inherited problems = ouch! Sorry I don't keep old list msgs, perhaps you mentioned this before: does the language skills field contain: 1 both the language and the skill-level, eg English - Advanced 1b what separator is used between the two words? 2 more than one language/skill-level where applicable, eg English - Advanced, German - Intro. 2b what separator is used between language entries? What is the database field description in the table schema? Please advise, =dn > well, I my opinion is not the way to work, but like I said the work was done > by other guy, and now I have the problem to solve. So i back to old question > :-) > How can I search with some precision in a serialized string? > > > > on 8/24/02 12:13 PM, DL Neil at [EMAIL PROTECTED] wrote: > > > Rodrigo, > > > > Then the question to be asked is: is serialize()ing this data good > > design/technique, or is there a better way? > > > > Regards, > > =dn > > > > > > > -- > 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] Re: SeparatingWords
Philip, What about "SoftwareVersion Thingy"? Won't that end up as "Software Version Thingy" - with two spaces before the "T"? Can the RegEx be 'turned off' if the u/case letter is already preceded by a space? (sorry, may not be Hessu's requirement = my curiosity) Regards, =dn > This works. > > $word = "SoftwareVersionThingy"; > $word = ereg_replace("([A-Z])", " \\1", $word); > $word = ltrim($word); > > -philip > > On Thu, 22 Aug 2002, Hessu wrote: > > > Hi, > > > > I have strings like FileName, SoftwareVersion etc. > > How can I add space between words? Somehow with preg_replace perhaps? > > First letter of each word is capitalized. > > > > -Hessu- > > > > -- > > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there a better way of doing this?
Hello Mike, parse a string similar > to "4,31m)" figure out if it is numeric or not, then if it is remove the > last to characters on the string (the 'm)') and change the string so > that it is 4.31. There is probably a better way of doing this but I > can't figure out how to make it better or more efficient > > $tim = "3,43m)"; > // take into account that the last 2 characters may not > be\ 'm)' like we are expecting, and store them in a var > $last2ontime = substr($tim,strlen($tim),strlen($tim)-3); > $tim = str_replace(",","",$tim); // get rid of the , in > the time (i.e. time = 3,43 and we want it to be 343) > $tim = substr($tim,0,strlen($tim)-2); > if(is_numeric($tim)){ > if($debug){ > print nl2br( "Time is Numeric!\n" ); > } > $t = substr($tim,0,strlen($tim)-2); > $te = substr($tim,strlen($tim)-2); > if($debug){ > print nl2br( "T = $t\nte = $te\n" ); > } > if(is_null($t) or $t == ""){ > $tim = $te[0] .".0". $te[1]; > }else{ > $tim = (string)$t .".". (string)$te ."m)"; > } > }else{ > if($debug){ > print "got else!"; > } Add the following code to the above (NB think you're a } short): $RegExIn = "3,43m)"; echo "With RegEx: $RegExIn"; $RegExPattern = "/(\d{1,3})(,)(\d{1,3})([a-z]{1,2})(.*)/i"; echo "RegEx ~$RegExPattern~"; $bValidity = $iFound = preg_match( $RegExPattern, $RegExIn, $aRegExOut ); if ( FALSE === $bValidity ) { $aLocated = NULLSTRING; echo 'Error interpreting RegEx'; } if ( 0 == $iFound ) { $aLocated = NULLSTRING; } if ( 0 < $iFound ) { echo "First number =" . $aRegExOut[1]; echo "Separator =" . $aRegExOut[2]; echo "Second number =" . $aRegExOut[3]; echo "Text unit =" . $aRegExOut[4]; echo "Additional non-text =" . $aRegExOut[5]; $value = $aRegExOut[1] . "." . $aRegExOut[3]; echo "Value = $value"; } Totally unsure about $last2ontime. The RegEx has been structured fairly loosely because I'm not sure of all the specifications for how many digits can be in the various places, etc; so feel free to altered the repetition values (inside the curly brackets) to suit. Of course, if the comma is missing or there is no integer value, (etc), then the whole thing will fall apart and give you nothing (hence the $aLocated = NULLSTRING; line which should probably be reworded/tied back to $value (yes I was reusing old code))! Hope it helps, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image library
> Having a large number of files in a single directory does affect performance, > the degree of which depends on the filesystem. This is generally accepted wisdom for dealing with large numbers of files - but what number is considered "large"? Any rules of thumb, for different OpSys/file systems? =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web site down?
General advice: take a look in the bottom right corner of any manual page and call for the mirrors list - it's worth bookmarking/favoriting a couple, just in case one goes down. Also FYI, mirror sites are often faster (depending upon relative locations) and their use certainly frees bandwidth at the central site. =dn > Thanks! Silly me, I'm always forgetting about the mirror sites ;) > > It is not just your paranoia. > > Be brave, step outside the contiguous 50 and try > > http://uk2.php.net/manual/en/ (it's working!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web site down?
> Is it just me having network connectivity problems, or is the PHP website, > http://www.php.net down? I tried connecting to it from a couple of > difference computers and I can't access it on any of them. Just wondering > if anyone else is having problems getting to their website too. Adam, It is not just your paranoia. Be brave, step outside the contiguous 50 and try http://uk2.php.net/manual/en/ (it's working!) Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image library
Hi Scott, Yes I am suggesting the naming of the image file by ascending number (at least in part - our Sony digicam produces files named DSCn.JPG). The danger of generating a filename by hash is that collisions are always possible. Moving to an 'accession number' removes that threat. The choice of locating the file in one or more sub-directories is a separate issue. After all, you could have one field in the db to keep track of the image's filename and another to keep track of its location - the two may or may not be related. Related: you can number/name the file and then use the last digit to determine which directory to locate it within (10 directories) - or the last two digits (100 directories). This has the advantage of spreading the directory/index load evenly as new images are 'accessioned'/arrive into the system. Non-related: you can use whatever algorithm you like, eg hashing or randomising, to decide where to place the image file. A low level of 'collisions' is immaterial in this application (whereas it would be catastrophic for image filenames)! Regards, =dn > So what you are suggesting is using an AUTO_INCREMENT field, possibly the > image's Primary Key as an identifier > for that image file., which is fine by me, but surely one should store files > across directories, as 1 images > in a single directory might slow down access to those images in the > filesystem, or not so? > > Thanks for your input. > > Regards > > -Scott > > > -Original Message- > > From: DL Neil [mailto:[EMAIL PROTECTED]] > > Sent: 21 August 2002 04:31 > > To: [EMAIL PROTECTED]; Bogdan Stancescu > > Subject: Re: [PHP] Image library > > > > > > Scott (confirming Bogdan), > > > > Libraries of all types have had this concern for years - even though books > > are uniquely identified by ISBN, that is still not good enough for library > > purposes (eg multiple copies of a single title). So they, exactly > > as Bogdan > > suggests, use an "Accession" number sequence - which can be > > implemented very > > neatly in MySQL (from PHP) as an AUTO_INCREMENT field. > > > > Regards, > > =dn > > > > > I've seen this kind of random approach several times and I keep > > > wondering why not counting the files instead. Yes, it may take a little > > > longer when uploading but I personally think the safety of the approach > > > is worth the insignificant speed sacrifice. > > > > > > Bogdan > > > > > > Scott Houseman wrote: > > > > Hi all. > > > > > > > > This confirms what I suspected. > > > > > > > > The hash algrithm: > > > > > > > > I have a directory structure: dirs 0 - f, and within each of > > these, the > > same > > > > dir structure 0 - f. > > > > When an image gets uploaded into the library, do an md5sum of > > the file, > > take > > > > the first 2 chars of that hash > > > > and there's your path. e.g > > > > $PICDBPATH.'/a/7/a7b8be10b0e69fe3decaa538f1febe84' > > > > > > > > I'm not sure what the mathematical randomness of this is, but I'm sure > > it's > > > > pretty random, and the chances > > > > of collision should be virtually null, the only time you should > > overwrite a > > > > file is if you upload the exact same file(?) > > > > Is there a better way of doing this? > > > > > > > > Cheers > > > > > > > > -Scott > > > > > > > > > > > >>-Original Message- > > > >>From: Justin French [mailto:[EMAIL PROTECTED]] > > > >>Sent: 21 August 2002 03:25 > > > >>To: [EMAIL PROTECTED]; PHP General > > > >>Subject: Re: [PHP] Image library > > > >> > > > >> > > > >>on 21/08/02 9:45 PM, Scott Houseman ([EMAIL PROTECTED]) wrote: > > > >> > > > >> > > > >> > > > >>>Which way would be the most efficient/fastest to access images > > > >> > > > >>from an image > > > >> > > > >>>library. > > > >>>A) Store image files in a hash directory structure AND storing > > > >> > > > >>each file's > > > >> > > > >>>information in a mysql table > > > >>>OR > > > >>>B) Storing image information in mysql table AND storing the > > >
Re: [PHP] Image library
Scott (confirming Bogdan), Libraries of all types have had this concern for years - even though books are uniquely identified by ISBN, that is still not good enough for library purposes (eg multiple copies of a single title). So they, exactly as Bogdan suggests, use an "Accession" number sequence - which can be implemented very neatly in MySQL (from PHP) as an AUTO_INCREMENT field. Regards, =dn > I've seen this kind of random approach several times and I keep > wondering why not counting the files instead. Yes, it may take a little > longer when uploading but I personally think the safety of the approach > is worth the insignificant speed sacrifice. > > Bogdan > > Scott Houseman wrote: > > Hi all. > > > > This confirms what I suspected. > > > > The hash algrithm: > > > > I have a directory structure: dirs 0 - f, and within each of these, the same > > dir structure 0 - f. > > When an image gets uploaded into the library, do an md5sum of the file, take > > the first 2 chars of that hash > > and there's your path. e.g > > $PICDBPATH.'/a/7/a7b8be10b0e69fe3decaa538f1febe84' > > > > I'm not sure what the mathematical randomness of this is, but I'm sure it's > > pretty random, and the chances > > of collision should be virtually null, the only time you should overwrite a > > file is if you upload the exact same file(?) > > Is there a better way of doing this? > > > > Cheers > > > > -Scott > > > > > >>-Original Message- > >>From: Justin French [mailto:[EMAIL PROTECTED]] > >>Sent: 21 August 2002 03:25 > >>To: [EMAIL PROTECTED]; PHP General > >>Subject: Re: [PHP] Image library > >> > >> > >>on 21/08/02 9:45 PM, Scott Houseman ([EMAIL PROTECTED]) wrote: > >> > >> > >> > >>>Which way would be the most efficient/fastest to access images > >> > >>from an image > >> > >>>library. > >>>A) Store image files in a hash directory structure AND storing > >> > >>each file's > >> > >>>information in a mysql table > >>>OR > >>>B) Storing image information in mysql table AND storing the > >> > >>image in a BLOB > >> > >>>field in that table. > >> > >>>From all accounts I've read on this list, a database is not > >>usually faster > >>than a filesystem. And for large amounts of files, like 1000's, > >>a hash will > >>speed it up more. > >> > >> > >> > >>>The way I see it, considerations to be taken into acount: > >>>- Is it quicker/better to retrieve image from table & then stream out to > >>>browser OR simply direct the browser to the file? > >>>i.e OR >>>SRC="/imagelib/5/f/10"> > >>>- Will a database OR filesystem be more scalable i.e. which wil perform > >>>better when there are 1 images in the libary? > >> > >>Filesystem should be quicker. You need to think about how you hash the > >>files up for the most even spread of files in each directory I guess. > >> > >> > >>Justin > >> > >> > > > > > > > > -- > 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] Agh! trim (#$@#@^%!!!)
Mike, What are the character codes of the last few bytes in the string? Please advise, =dn - Original Message - From: "Mike At Spy" <[EMAIL PROTECTED]> To: "Rasmus Lerdorf" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, August 21, 2002 1:36 PM Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) > > Get this - it didn't work! :( > > I tried decreasing the -1 to -2 and so on, but nothing on that either. :( > > -Mike > > > > > -Original Message- > > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, August 20, 2002 12:45 PM > > To: Mike At Spy > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > Well, perhaps you have something after the . in that string? > > > > You can strip off the last char of a string very simply with: > > > >substr($str,0,-1) > > > > -Rasmus > > > > On Tue, 20 Aug 2002, Mike At Spy wrote: > > > > > > > > Hey! > > > > > > :) > > > > > > I have an issue with trim / triml. Whenever I put a string in > > to trimmed, > > > it refuses to take the period at the end of the string off. > > > > > > I did put more things to trim first, but this is basically what > > I am doing: > > > > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > > $trimmed = rtrim($date, "."); > > > > > > > > > Is there an issue with this? I've tried using trim() too. > > > > > > The source of $single is a reponse from a server. I should > > note that when I > > > put this in as an experiment, it works fine. When I get the > > line from the > > > server, it doesn't work! > > > > > > The only thing I can think of is the possibility that the "." I > > am seeing at > > > the end of the line isn't really one (it looks like a duck, > > copies like a > > > duck, but...isn't a duck??!!). > > > > > > Is there a way to just strip the last character off regardless > > of what it > > > is? > > > > > > Thanks, > > > > > > -Mike > > > > > > > > > > > > -- > > > 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Find rows by 1st letter in MySQL
Tony, > How would I go about selecting rows from a MySQL table where the first > letter of a certain field is $letter ? Depends upon the MySQL tbl's schema. The MySQL online manual discusses wildcards (full text). Alternatively see LEFT() and other string functions that can be used in SELECT and WHERE clauses. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] hyperlink parser - a bit new view :)
Hi Roman, > But on those phpbuilder's page there are also similar questions but answered > scripts don't work, for example: > ... > preg_match_all("|href=\"?([^\"' >]+)|i(+[ >])", $text,$ar); >... > I really don't know :( There's definitely something wrong with the RegEx above. The string commences with |, so therefore the last characters of the string must be |a - where "a" is a letter, in this case "i" meaning case-insensitive. For some reason the |i is not at the end of the string - either you miscopied or they misprinted. However the RegEx doesn't strike me as correct HTML anyway, because there can be spaces between elements, eg between "href" and "=", eg ]*)(['\" >])/i"; if ( DEBUG ) echo "RegEx=$RegEx~"; $bValidity = $iFound = preg_match_all( $RegEx, $HTML, $aRegExOut ); An improvement might be for the closing quotes to refer back to (any) opening quotes. I am willing to watch, listen, and learn, if anyone can offer improvements/wisdom. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fgets question
Hi Monte, > Hi, I have a question about fgets(), it seems to pick up an extra line > at the end of a text file. ... > 8\n ... > Here is the output (showing newlines as \n): > buffer is 1\n > buffer is 2\n > buffer is 3\n > buffer is 4\n > buffer is 5\n > buffer is 6\n > buffer is 7\n > buffer is 8\n > buffer is > My question, why is there an extra line? Or in other words, how do I get > this to loop exactly 8 times if there are only 8 lines? The answer is that there isn't an 'extra' line, there are as many as you put/PHP reads! The question to ask is: how does a stream file end? Answer: with an EOF character (not an LF). Lines in a (*nix) stream file are separated by LF or \n character, therefore there is a ninth 'line' (of absolutely nothing) between the last LF and the EOF. Take out that last \n and things should work the way you want. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL datetime ERROR !
Hi Djurovski, > I use this query to input data into MySQL DB. > EXPIRE is Expire Date! > My script allways inputs "1.1.0001" into database (as value of expire). > what is wrong? > > My table: > > CREATE TABLE korpa ( >idnarudzbeukorpi int(255) DEFAULT '0' NOT NULL auto_increment, >mernaj varchar(255) NOT NULL, >nazivproizvoda varchar(255) NOT NULL, >ip_adresa_narucioca varchar(255) NOT NULL, >id_proizvoda varchar(255) NOT NULL, >kolicina_proizvoda decimal(255,2) DEFAULT '1.00' NOT NULL, >cena decimal(255,2), >datum datetime DEFAULT '-00-00 00:00:00' NOT NULL, >expire datetime, >PRIMARY KEY (idnarudzbeukorpi) > ); > > MySQL query: > > $aSQL2="insert into korpa (mernaj, nazivproizvoda, ip_adresa_narucioca, > id_proizvoda, cena, datum, expire) values ('$mernaj', '$naziv', '$ip', > '$id', '$cena', now(), now()+3000)"; Adding apples to oranges? expire is a datetime column. what format does now() produce its result in? can an integer (3,000) be added to that? =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch statement question
Alternatively Alexander, take a look at the string functions eg strstr(), stristr(), and strpos() all of which can be used to make a condition within the case() criteria. Regards, =dn > [snip] > Say i have a variable $string_var = "Once upon a time"; > > is there a way to do this: > > Switch($string_var) > { > case(contains "Once"): >doSomething(); >break; > case(contains "the end.") >doOtherThing(); >break; > case(contains "time") >doNothing(); >break; > default: > echo "ERROR" > } > [/snip] > > http://www.php.net/manual/en/control-structures.switch.php > > Yes Virginia, there is a PHP function :^]. You can explode your $string_var > into an array, loop through the array and test each word for a match. > > HTH! > > Jay > > > > -- > 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] SQL ?
Now then, let's all play nicely together! Dan: relevance It is a PHP question because whereas the SQL query SELECT fred FROM tbl produces an array element back in PHP such as $row[ "fred" ], this convention/mapping comes well unstuck if you submit something like SELECT IF ( answer = 'a', TRUE, FALSE )... or even SELECT fred+barney... Accordingly the need to create an alias column name (Answer-A) and thereafter in PHP to access the returned data with something like $row[ "Answer-A" ]. Tyler: appreciation and politeness I thought this looked familiar, and it is part of something I sent to you 36 hours ago to perform cross-totalling on a survey or exam results type database. Since then there has been no comment from you, except to others. If the suggestion doesn't work, please have the courtesy to come back to me, at least by cc:, for correction or amplification. NB If you had tested it at the MySQL (?) command line or using a management tool (recommended testing procedure before implementing in PHP), then you would have observed the result. Dan is often here, being helpful. Did you really mean to irritate two people by thoughtlessness if not deed, during the course of a single conversation? =dn > Why not just let such a simple question go then? Especially since your reply > is also off topic? Also, the question I asked was part of a reply from a > previous topic. Thanks to all who answered my "simple" question. It is > greatly appreciated. > >On Mon, Aug 12, 2002 at 02:15:23PM +, Tyler Durdin wrote: > > > SELECT *, IF (answer = 'a', TRUE, FALSE) AS Answer-A > > > What does the As Answer-A mean and what does it do? > > > >Why not examine the manual for the answer to such a basic question, > >especially one that is off topic for the list you posted to? > > > >Assuming you're using MySQL read http://www.mysql.com/doc/en/SELECT.html > >and you'll quickly come across the meaning of AS. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] records in db
Tyler, > If I have a field in my DB that can have 4 different answers, lets say a,b,c > and d. How can I count the number of each in that field. So if there are 4 > a's 1 b 0 c's and 12 d's how can I get php to count this? You must combine IF() with SUM(). Break it down into smaller problems: 1 getting the data out of the tbl and grab all of the answer rows 2 'count' the number of "a"s 3 do the same for the number of "b"s The first is trivial, but let's limit our attention to question 1 until we figure out how to word the query: SELECT questionNr FROM tblNm WHERE questionNr = 1 AND answer = 'a' Obviously this won't satisfy you - you don't want line after line of data, and it only works if the chosen answer is "a" and you read off the number of rows affected. What happens if the answer is "b". We'd have to execute the query all over again, but substituting "b" for "a". Is there another way? Yes, there is an IF() in SQL (manual: 6.3 Functions for Use in SELECT and WHERE Clauses). Let's try listing the question number and noting if the answer is "a" or "b" or...: SELECT questionNr, IF( answer = 'a', TRUE, FALSE ) AS Answer-A, IF( answer = 'b', TRUE, FALSE ) AS Answer-B, ... FROM tblNm WHERE questionNr = 1 Now we have a list of all of the answers to question 1, but instead of only "a" answers, we have a column of TRUEs and FALSEs for the "a" answers, and beside that a column of TRUEs and FALSEs for the "b"s, through "c" and "d". So beside the questionNr we have four columns telling us which data is relevant to count - if we simply count the TRUEs. So we've saved the repetitious executions, but the machine no longer does any useful counting for us. Substitute 1 for TRUE and 0 for FALSE, and we can have SQL do that last calc for us, ie SUM all of those "TRUE" values: SELECT questionNr, SUM( IF( answer = 'a', 1, 0 ) ) AS Answer-A, SUM( IF( answer = 'b', 1, 0 ) ) AS Answer-B, ... FROM tblNm WHERE questionNr = 1 Finally, if you get rid of the WHERE clause, and replace it with GROUP BY questionNr, it should work for every question in the test/survey. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save ability... Duplicate DB entries
JJ, > i have this code snippet: > > if(isset($_POST['save'])){ > $query = 'INSERT INTO article_data VALUES (\'\', '.$_SESSION['uid'].', > '.time().', \''.$_POST['title'].'\', \''.$_POST['description'].'\', > '.$_POST['cat'].', \''.$_POST['text'].'\', 0)'; > $result = mysql_query($query) or die("Query failed: $query" . > mysql_error()); > echo 'you saved your work.'; > } elseif(isset($_POST['pub'])) { > $query = 'INSERT INTO article_data VALUES (\'\', '.$_SESSION['uid'].', > '.time().', \''.$_POST['title'].'\', \''.$_POST['description'].'\', > '.$_POST['cat'].', \''.nl2br($_POST['text']).'\', 0)'; > echo 'you published your work.'; > } > > Which has a save or a publish option. I only want to keep one copy of each > article in the DB. This adds a new one each time. I know about updates in > SQL but the file may or may not already be in the db. Does anyone have a > good way to go about this? First perform a SELECT to establish previous existence (can lock row at this point, if using suitable RDBMS), then decide to INSERT or UPDATE, save or publish. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restricting access using IPs
Liam, Not altogether happy with the suggestion below. It works - for now. A more generic solution might be to replace the hard-coded "9" with a call to strrchr() on the last 'dot' character position (minus one). Then it should work on any properly formed IP address. Thereafter parameterise the subnet address portion and things become mobile/re-usable. Regards, =dn > Oops, wrong variable. That should be: > > $substring = substr($REMOTE_ADDR,0,9); > > if ($substring == '192.168.0') > { > // you're in > } > > Michael > > > On Sat, 13 Jul 2002, Liam MacKenzie wrote: > > > > > If I enter 192.168.0.13 (My IP) it works, I'm allowed in and any other IP > > > isn't. > > > However, I need to grant access to this whole network, not just me. So I > > > need 192.168.0.* to be able to access it, everyone else should get "Access > > > Denied" > > > > > > So I need to know how to write this bit: > > > $localip = "192.168.0.13"; > > > so that it's the network, not just me. > > > > > > I tried these but they didn't work: > > > $localip = "192.168.0.0"; > > > $localip = "192.168.0.*"; > > > $localip = "192.168.0.0/24"; > > > > > > > > > Any other ideas? > > > > > > Cheers > > > > > > > > > > > > - Original Message - > > > From: "Jason Wong" <[EMAIL PROTECTED]> > > > To: <[EMAIL PROTECTED]> > > > Sent: Saturday, July 13, 2002 3:49 PM > > > Subject: Re: [PHP] Restricting access using IPs > > > > > > > > > > On Saturday 13 July 2002 13:10, Liam MacKenzie wrote: > > > > > Hey all, I'm looking to deny access to all IPs except those that fall > > > into > > > > > a specific IP range. 192.168.0.* in this case. > > > > > Am I missing something out of this code, it don't work too well ;-) > > > > > > > > HOW doesn't it work too well? It displays a picture of a naked guy instead > > > of > > > > the naked girl that you was expecting? > > > > > > > > > > > > > $localip = "192.168.0.13"; > > > > > if ($REMOTE_ADDR == $localip) { > > > > > ?> > > > > > > > > > > Allowed! > > > > > > > > > > > > > > } > > > > > else { > > > > > ?> > > > > > > > > > > Denied! > > > > > > > > > > > > > > } > > > > > > > > > > ?> > > > > > > > > > > > > -- > > > > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > > > Open Source Software Systems Integrators > > > > * Web Design & Hosting * Internet & Intranet Applications Development * > > > > > > > > /* > > > > GOOD-NIGHT, everybody ... Now I have to go administer FIRST-AID to my > > > > pet LEISURE SUIT!! > > > > */ > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > n i n t i . c o m > php-python-perl-mysql-postgresql > > Michael Hall [EMAIL PROTECTED] > > > > -- > 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] hello the list
Welcome Nicolas, =You didn't actually say what the problem was! =Some have made suggestions, please also consider (below): i'm new and i'm trouble with this code :'( can U help me please ?? this is the code : while ($cd_tbl = mysql_fetch_array ($result)) { $cd_id = $cd_tbl['cd_id']; $cd_oeuvre = $cd_tbl['cd_oeuvre']; $cd_chef = $cd_tbl['cd_chef']; $cd_compositeur = $cd_tbl['cd_compositeur']; <---partie concernée-> //-Debut Seth //-- // name : _ALTERNANCE_COULEUR_ // desc : test de 'id' pour l'alternance de couleur //-- if(is_int("$cd_id") = TRUE) =there is no need for the double-quotes in this statement. =you should be coding equality (==) or even equality and type equivalence (===) Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] PHP editor for windows
> > "etc" (TM) is able to follow up the syntax coloring operation by making > > changes to the code to correct syntax errors, puts brackets in exactly > > the right place to indicate block structure within the code, imposes > > data type prefixes in strict convention, chooses better variable names > > than any caffeine-driven prog, and alerts designers to most logic errors > > (the paid-support version guarantees a higher rate of success at the > > last). Only the M$ version enforces rules. All other OpSys users can/will do what they like. > How about enforcing/auto-correcting to the One True Brace Style (version > 42.0)? It works with parentheses, brackets, braces, etc. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP editor for windows
> I really hate to do this, but it's one of my pet peives. is that like a pet rock? BTW if we're exercising peevishness, at the same time as indulging in anally non-retentive breakfast habits, check out http://www.onelook.com/cgi-bin/cgiwrap/bware/afen.cgi?type=word_all&word =peeve > >>> Other than notepad, interdev, ultraedit, etc (which i currently use > >>> for > >>> editing), does anyone know of a good editor for PHP for Windows, > >>> ideally > >>> with syntax colouring, etc? > >> You use etc for editing? Sounds pretty cool. This is a new product Erik, only released at the beginning of this month, so it's no surprise that you haven't seen it in use yet. "etc" (TM) is able to follow up the syntax coloring operation by making changes to the code to correct syntax errors, puts brackets in exactly the right place to indicate block structure within the code, imposes data type prefixes in strict convention, chooses better variable names than any caffeine-driven prog, and alerts designers to most logic errors (the paid-support version guarantees a higher rate of success at the last). =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculating US holidays OT
> > I need to calculate the date to see if it's a holiday, i.e. is today > > presidents day > > No, today is Patriot's Day! > > Not sure if it's celebrated outside of Massachusetts It's celebrated any day there's a SCUD inbound! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web spider?
Greg, > >i was wondering if it would be possible to make a web spider in PHP. > >they work by download a website, then following all the links on the > >website to other pages, and then following the links on that page... > > > >is this possible in PHP without a whole lot of work? i just want to keep > >a counter of how many links (not e-mail addresses or file downloads) it > >finds. if someone has the time, could you write up a quick recursive > >script that i could use as a basis of my project? > > Well, I love PHP, but this sounds more like a job for C/C++. The reason > being is the socket support in C/C++ is way better than that found in PHP. > Harder to code mind you, but better in the end. I learned from the manual and coded up a quick page-reader/status checker using fopen and fread - and thought I was fairly clever for something so 'quick and dirty'. However perhaps this approach would not work if something a bit more 'demanding' was required. Please would you explain the advantage/necessity for using sockets (would appreciate pointers to any reading/tutorials). Thanks, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP FAQ (again)
Justin, > I think this is a good idea, but it looks to be more of a searchable FAQ, > which will highly detailed... I'm really thinking of a medium-length email > introduction to the group (as per my attachment) which hopefulyl cleans up > the group a bit. > > Your resource could be fantastic, and could help with what i'm talking > about, but isn't really the answer *I* had in mind :) > > > Half the problem is that newbies AREN'T searching before asking Q's, or > don't know where to search, or don't know the right question to ask... so > any huge FAQ will not help this problem -- even though it will be a great > asset to the community. All sounds like a good idea. Your first post was at least half-way there, so why don't you, in true open systems style, take the lead and gather a group of other like-minded and motivated people, and just Nike/do it? Unfortunately the benefits are predicated on two things: 1 the unreasonable: will the newbie/questioner bother to consult any FAQ before putting fingers to keyboard? At the one extreme we have people who don't even notice that there are unsubscribe instructions at the end of every msg, and beg to be released from membership (and please encourage them to go - bless 'em!) Another is the person who is so bound up in his/her work or perhaps naturally self-centered, that (s)he can justify 'breaking' any 'rules' because "I JUST need to know NOW" (those three capitalised words saying it 'all'). I've had three and four-round correspondence with several ratbags where the last contribution from me boils down to "read what I wrote in paragraph-n of my first reply" and from them "Sorry, I've been working continuously for 17hours and can't see straight" (to put it politely - and sometimes they don't feel it necessary to thank/apologise...) 2 the reasonable: the worst problem a newbie faces is working out the terminology/jargon. I'm currently helping someone working in MS-Excel and disappearing deep into the bowels of macros/VBA. His system is German language, and mine English. Often my problem is working out first the 'M$ word' for something by chasing through the KnowledgeBase, and then perhaps working out how to translate it into German-Excel... Anyone who has (also done something bad in a previous life) worked with M$ products is familiar with this problem/feeling. The same applies here: a newbie might talk about a 'logon and a password' without knowing that the online manual's search engine will answer his/her question in a flash if the word "authentication" is used... Yes a bit of thought in the amount of info given (not too little, not too much - quite a tall order when you're seeking an answer to something you don't understand!), and the quality of message titles/subjects, does go a long way towards motivating me (at least) into considering taking the time and trouble to reply, etc, etc. Go for it! =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning: Undefined variable
Erik, My two cents' (with allowance for inflation...) > > If you're distributing code in cyberspace it's a good > > idea to make it error free too, E_NOTICE or otherwise. To get the maximum help when coding, and to ensure the minimum of confusion for your users, I recommend: 1 set the dev server's PHP error setting to catch every single error/warning msg, and code well (?code Shell) 2 set the prod server to not report any errors except a complete disaster to the user (?catastrophe theory) If they are one and the same machine/server, then use 'debug' code to reset options at the beginning of dev code (and remove it when the routine is 'promoted' to prod). > I got back quite a few responses on this list on the subject of having > variables that are not defined before they are used. That's > interesting -- it's nice to know that I can take shortcuts and conjure > them up on the fly, but I didn't realize that it was good practice to > declare the variable before you actually use it in a script. (I never > studied programming in any formal sense, as anyone who has seen my > source code can attest :). > > Sometimes I create variables dynamically, such that I could never > declare/initialize them in any realistic sense -- for instance, I might > have a while loop that executes a number of times equal to the number of > rows pulled from a database query. And in this while loop, I might > generate a new variable (assigning it a name like $variable$i, using the > old $i++ trick to give it a unique numeric suffix). > > If I use this trick, does this doom me to never having fully-error-free > code? Or is there something that I'm not getting here... The short of > it is that, as a novice programmer, I'd like to make sure I'm writing > the most legitimate code that I can. Thanks for any input on this > thread, past or future. In strongly typed languages, I think there are (?have been historically) two objectives in defining variables prior to their use: 1 to set aside the storage space, and 2 to define the variable type 1 in the case of a scalar variable this seems trivial, eg INTEGER J Dim intJ As Integer In the case of an array or var/set length string, then replication needs to be added into the equation for calculating both an individual component's address and working out how much storage to set aside, eg INTEGER K(10) 2 Somewhat obviously a double-precision floating point number will require more space/bytes to store its value than a simple integer. However a common error made when programming is that you think a variable holds data of a certain type, when in fact you earlier used it in some other (very similar, but not quite the same) manner. eg //don't use this code $User = "Fred"; later on we do (say) a db call and pull out a row of personal data: $query = "SELECT * FROM persTbl WHERE persId = '$User' "; //I'm assuming that persId is likely some sort of personnel/membership number PHP is a 'little ripper' when it comes to quick and dirty usage, because you don't have to type a declaration line before using a variable/assigning storage (per part (1)) - PHP works it out for you/from context, so it can 'very fast' (from a coder's point of view). However such does leave one open to the problems described in part (2) - which a strongly typed language would flag as an error! To this end, some people decide to describe the usage of each variable as part of the name. For example I was reading some Microsoft Excel macro/VBA stuff and there's talk of intCounter and txtNameEntered - for an integer value and the contents of a data-entry form's text box (resp). You have gone on to describe how the PHP attitude to typing enables the creation of dynamic variables/variable names. This is a really powerful feature, and has an important place in certain functions. However it is not something I would put into an intro tutorial, because with such power comes the potential to greatly expand the size of feet before bringing them into close proximity with one's mouth! One of your correspondents pointed out that a really good compromise is the associative array - the variable name (array name) stays 'constant', but the array argument/pointer can be almost anything as a 'label'. As another aside, it is also an 'advance' to know that the various contents of an array in PHP do not have to be all the same datatype (as they do/did in other languages)! Thus: $aPersRow[ "persId" ] = 12345; //integer $aPersRow[ "persNm" ] = "Fred"; //string $aPersRow[ "persDoB" ] = "1970-01-01"; //date cf INTEGER K(10) setting aside space only for a collection of integers! One way that I have utilised this technique is to keep a set of counters for system/logging/reporting purposes in an associative array. The array element/label is self-documenting, and the ability to pass them all into a reporting sub-procedure as a single parameter/array name provides an easy cohesion/grouping! In PHP I have found it helpful to do something similar t
[PHP] Re: [PHP-DB] how to get consistent UTC from gmmktime (w/o dst-offset) ????
uot;continues incorrect" . "" ; echo "" . "Run above (incorrect) gmTS through gmdate()" . "" . "" . gmdate( "D d.m.Y H:i I", $gmmkLoc ) . "" . "continues incorrect" . "" ; echo "" ; $tsLoc = mktime( ); $tsGMT = gmmktime( ); echo "" . "*mktime( NOW)" . "" . date( 'D d.m.Y H:i I' ) . "" . "$tsLoc" . "$tsGMT" . "think they should be same?but GMT doesn't like it!" . "" ; $tsLoc = mktime( 0, 0, 0, 3, 31, 2002 ); $tsGMT = gmmktime( 0, 0, 0, 3, 31, 2002 ); echo "" . "put change-over date into *mktime to get TSs" . "Sun 31Mar2002 02:00" . "$tsLoc" . "$tsGMT" . "againnot same!?" . "" ; echo "" ; echo "" . "Count from midnight over GMT/BST changeover:" . "" ; echo "" . "by putting LocalTS ($tsLoc) into *date" . "Local time jumps..." . "GMT continues..." . "" ; for ( $iOffset = 0; $iOffset < 5; $iOffset ++ ) { $iHour = $iOffset * 3600; echo "" . "Midnight+$iOffset" . "" . "" . date( "D d.m.Y H:i I", $tsLoc + $iHour ) . "" . "" . gmdate( "D d.m.Y H:i I", $tsLoc + $iHour ) . "" . "" . "" ; } echo "" . "by putting GMT TS ($tsGMT) into *date" . "" . "" . "garbage?!" . "" ; for ( $iOffset = 0; $iOffset < 5; $iOffset ++ ) { $iHour = $iOffset * 3600; echo "" . "Midnight+$iOffset" . "" . "" . date( "D d.m.Y H:i I", $tsGMT + $iHour ) . "" . "" . gmdate( "D d.m.Y H:i I", $tsGMT + $iHour ) . "" . "" . "" ; } echo "" ; ?> Patrick: herewith specific answers to your most recent msg:- Yes, as mentioned I am in GMT (London). However the tests run (over the next one week period) are valid because during this weekend we cross-over into BST (GMT+1) and try (vainly) to catch up with you. Thus the tests below ARE valid and illustrate your very point, because the date-ranges span the summer time discontinuity. (so I don't need to run it on another box/change the server's TZ setting, I simply read the second half of the report) It is not missing one day, but one hour! Regards, =dn > Fucko. I kicked this pony-style. Yes - typo Didn't know what hit me there. > Output is as you said. Gotta have been drunk or something... But anyaway, > that's not really the point. > > The point is, that in the count-days-version you're sort of missing a day: > > > 1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0 <<<<<< > > 1017532800= mktim epoch - Sun 31.03.2002 00:00 0 > > > > 1017619200= gmmktim epoch - Mon 01.04.2002 00:00 0 <<<<<< > > 1017615600= mktim epoch - Mon 01.04.2002 00:00 1 > > Now, for some reason (and I REALLY got this checked for typos now) the > 'count second'-version ends up showing me 23:00 0 of the previous day > consistently. It IS consistent throughout DST changes. But it's one hour > off when created with mktime and printed with gmdate. And I can give you > the reason: Taken from your email-adress you're in TZ+/-0, right. And that's > the ONLY location where gmmktime(0,0,0,28,3,2002) actually gives you the > epoch stamp of that date. If I do it, my timezone gets subtracted and I > end up with the epoch stamp of 23.00 of the last day (my TZ beeing +1). > > ufff - hope I made my point clear. It's just that gmmktime is still > somehow localized. So for mew it would mean that I have to subtract > my TZ everytime I use gmmktime to get the correct epoch. > > Just try running the code on a box that's not in TZ 0 and you'll see > what I mean. > > > greets, > patrick./ > > > > > DL Neil wrote: > > > > Hi Patrick, > > > > > before spamming the group with this, let's see if we're talking about > > > the same here: > > > > It would not be "spam"! It is list business, and copying the list gives > > others the opportunity to answer before I do/offer other ideas - and > > others following the discussion the opportunity to learn... > > > > > I completely agree with your points, but if I execute the two lines > > you > > > propose from here (TZ+1, no DST): > > > > > > echo gmdate (&
[PHP] Re: [PHP-DB] how to get consistent UTC from gmmktime (w/o dst-offset) ????
BTW for all who are following this, Patrick has cleverly illustrated that most of the northern hemisphere locations where summer time is observed will 'spring forward' this weekend. Most of the southern hemisphere locations that were in summer time did their 'fall back' last weekend! NB the two uses of the word "most"! Hi Patrick, References from the manual: - gmmktime -- Get UNIX timestamp for a GMT date - gmdate -- Format a GMT/CUT date/time Identical to the date() function except that the time returned is Greenwich Mean Time (GMT). For example, when run in Finland (GMT +0200), the first line below prints "Jan 01 1998 00:00:00", while the second prints "Dec 31 1997 22:00:00". echo date ("M d Y H:i:s", mktime (0,0,0,1,1,1998)); echo gmdate ("M d Y H:i:s", mktime (0,0,0,1,1,1998)); - The definition of the Unix Epoch is itself in GMT (and adjusted from there to local time using the +/-TZ difference): "the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)". When playing around with UNIX epoch seconds it is important to keep them time-zone separated. So try working your test backwards and putting in a data/time and then asking for the GMT and the local timestamp values. They will also be separated by the one hour/two hours. Question answered, or in my haste to get to my dinner...? Regards, =dn > i'm storing events in a mysql-db, using epoch timestamps to pinpoint the > exact date/time for an event. > > so far, I have been using localtime, being aware that there are > inconsistencies > in the number of epoch-seconds, when DST flips on and off. nevertheless, that > works fine as long as you stick to mktime() and date() for all the date-math > as in mktime(0,0,0,$month,$day+$offset,$year) > > but as soon as you leave php and have to do some calculation in javascript, > you will encounter functions that behave differently on the pc and mac > platforms. so you have to revert back to the 'add 86400-seconds' to calculate > the next day. > > so I thought it would be nice to have all the timestamps as linear, > non-dst-epoch-seconds (UTC) and I went into the gmmktime() and gmdate() > functions, assuming they would do the math in a linear second-based timespace > (in GMT, without DST). That seems to be the case for the output of 'gmdate', > that remains correct, if you count up seconds across the DST boundary (see > second example). > > but it seems that there is no way to calculate the gmt-epoch for a given > date using gmmktime without having to add/subtract the TZ manually. gmmktime > will always take your local DST-settings into calculation and upon conversion > back with gmdate, you will be off by the number of hours of your timezone. > I thought gmmktime() would handle this as if the computer would be in > Greenwich > (TZ=0), which would then leave us with the two functions encoding/decoding > consistently. > > anyone having solved this properly? > > - > print "count days:\n"; > for($day=0; $day<7; $day++){ > $timgmt = gmmktime(0,0,0,3,28+$day,2002); > $timloc = mktime(0,0,0,3,28+$day,2002); > print $timgmt . "= gmmktim epoch - " . gmdate("D d.m.Y H:i I",$timgmt) . > "\n"; > print $timloc . "= mktim epoch - " . date("D d.m.Y H:i I",$timloc) . > "\n"; > print "\n"; > } > > > count days: > 101727= gmmktim epoch - Wed 27.03.2002 23:00 0 > 101727= mktim epoch - Thu 28.03.2002 00:00 0 > > 1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0 > 1017356400= mktim epoch - Fri 29.03.2002 00:00 0 > > 1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0 > 1017442800= mktim epoch - Sat 30.03.2002 00:00 0 > > 1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0 > 1017529200= mktim epoch - Sun 31.03.2002 00:00 0 > << 1017619200= gmmktim epoch - Mon 01.04.2002 00:00 0 <<< off by one hour due to > DST > 1017612000= mktim epoch - Mon 01.04.2002 00:00 1 > > 1017705600= gmmktim epoch - Tue 02.04.2002 00:00 0 > 1017698400= mktim epoch - Tue 02.04.2002 00:00 1 > > 1017792000= gmmktim epoch - Wed 03.04.2002 00:00 0 > 1017784800= mktim epoch - Wed 03.04.2002 00:00 1 > > > - > print "count seconds:\n"; > $baseepoch = $timloc = mktime(0,0,0,3,28,2002); > for($day=0; $day<7; $day++){ > $epochnow = $baseepoch + (60 * 60 * 24 * $day); > print $epochnow . "= gmmktim epoch - " . gmdate("D d.m.Y H:i I",$epochnow) . > "\n"; > print $epochnow . "= mktim epoch - " . date("D d.m.Y H:i I",$epochnow) . > "\n"; > print "\n"; > } > > count seconds: > 101727= gmmktim epoch - Wed 27.03.2002 23:00 0 <<< consistent, but off by > -1 (your TZ) > 101727= mktim epoch - Thu 28.03.2002 00:00 0 > > 1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0 > 1017356400= mktim epoch - Fri 29.03.2002 00:00 0 > > 1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0 > 1017442800= mktim epoch - Sat 30.03.2002 00:00 0 > > 1017529200= gmmktim epoch - Sat 30.03.2002
Re: [PHP] Problems installing PHP
Hi Berlina, > Im trying to install an Apache Web Server and PHP in a Windows NT . > > * Apache 1.2.23 > * PHP 4.1.1 > * Windows NT Server 4.0 with SP4 > > The installation of Apache Web Server and PHP was succesfully ok, but when I > configure the PHP and Apache, editing the PHP.ini and httpd.conf files, as > installation manual says, was not any problem neither. > > The problem appears when i try to load a php file with the web server, then > shows all the content of a file. The server reads and show the file but not > execute it. > And, of course I added the lines: > LoadModule php4_module PATH/php4apache.dll > AddType application/x-httpd-php .php > in my httpd.conf file. My (NT) system is Apache 1.3.20, PHP 4.0.6, NTWS 4.0 SP6a Entries in httpd.conf that you didn't mention: ScriptInterpreterSource registry and in: ScriptAlias /php/ "C:/Program Files/PHP/" later (in addition to what you described) in: Action application/x-httpd-php "/php/php.exe" AddType application/x-httpd-php .php .phtml .php3 .php4 - watch those PATHs!? I'm not sure if any/all of them might be useful to you - I'm no Apache specialist, but I followed the instructions given and everything runs really well. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mktime() into TIMESTAMP ?
Hi Erik, > On Wednesday, March 6, 2002, at 05:11 AM, DL Neil wrote: > > > My 'rules' are simple: > > If the date/time is for processing, keep it as a timestamp (consider > > which type). > > If the timestamp is being used to keep track of RDBMS activity, then > > use a TIMESTAMP column. > > By RDBMS activity, do you mean "last time user performed x query" ? > In fact, one of my columns is in fact designed to record things like > "last time user logged in" or whatever, but I am not using the > auto-bumping ability of the TIMESTAMP column, but rather creating a new > INSERT statement and mysql_query() function to do this job. Either UPDATEing or INSERTing will cause an unspecified (first) TIMESTAMP column to be set to NOW(). If it is recording last login, then surely it makes more sense to UPDATE? Yes, the TIMESTAMP 'bump' is useful to record 'last activity' applications. > > If RDBMS auto-update would foul things up, use an integer data type. Whereas when I am recording timestamp data, but don't want the 'bump' facility, then I store UNIX TIMESTAMPs in (suitably wide) INTEGER fields (which won't 'bump' under any conditions). > > If the date/time is for people/presentation, use a textural format. > > I'm thinking of not storing any plaintext dates, simply because it's > easier to format the mktime() result or TIMESTAMP column to suit my > needs. In fact, combining mktime() and date() really seem to be the way > to go, which is why I'm using mktime()-generated Unix-style > timestamps -- I'll probably never do any database output directly from > mysql[client], but rather everything from PHP or perhaps Python if I > ever get the time to work on that side project.* Now if you mean UNIX TIMESTAMP as an integer (*not* MySQL TIMESTAMP) that's exactly what I decided (excepting that I'm using PHP's GM* functions and converting everything to UTC). The 'downside' is that looking at the table contents is an eye-straining experience, so the first thing you have to do is write a debug retrieval query that will present the data in 'English'/a more readable form. > > If there will be minor processing on the column, eg GROUP BY, ORDER > > BY, or even >, =, etc, then use ISO format > ISO = MySQL-style TIMESTAMP? > If so, then can't you do ORDER BYs and >, = queries with the Unix-style > mktime()-generated integers as well? I'm not very experienced with the > more advanced MySQL features, though I know they're there and have a > decent reference should my script require them. Careful! ISO dates are in CCYY-MM-DD format, as per MySQL DATEs. MySQL TIMESTAMPs are in 'integer' format, still CCYYMMDD but don't try using them for arithmetic! Yes you are correct you can perform each of the above comparisons on both data formats. I didn't mean that you should interpret some 'exclusivity' in those (somewhat informal) 'rules'. What I was saying was that the CCYY-MM-DD format (cf TIMESTAMP) suits 'presentation' but can also be used for simply manipulations, eg comparisons. However, backing up a paragraph or two, I pointed out that the other temporal format is to be used when calculations are required (and presentation is less of an issue). The attempt was to illustrate when you might use one format and when the other. > > If there will be no processing between what comes out of PHP and what > > PHP wants back, use a string format column. > > That's what I was thinking. Apart from some simple queries for results > whose dates are between x and y (which should work with > mktime()-generated timestamps, right?), it seems that this is the best > policy. I should change those columns from TIMESTAMP to INT now before > I go any further, just so that I don't accidentally ever bump up the > value of the column via an insert or update... > > > Yes you should remember that MySQL will happily cast between string and > > integer alternative presentations! > > I'm not sure I understand what this means. I'm guessing that you're > suggesting that an INT or a VARCHAR column can both have mathematical > operations performed on their values, but perhaps I'm completely > off-base. My SQL skills are miserable... I need to brush up. (Too much > time spent learning PHP lately!) "Cast" means to set/reset a value in one datatype/format to another datatype, eg converting a character="1" to an integer=1, or as you say, a TIMESTAMP value (of either kind) to an integer - or a string DATE=CCYY-MM-DD to its integer equivalent=CCYYMMDD. > > Your take/critique welcomed! > > More like questions than critique! All encourages clarity of thinking and expression! Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php