Re: [PHP] Auto-generating HTML
On Mon, Sep 20, 2010 at 03:02:35PM -0400, TR Shaw wrote: On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote: Hey folks, I have the feeling this is a stupid question, but I can't even find anything about it. Maybe I'm just not searching for the right things. Here's the problem. I'm writing a lot of pages, and I hate going in and out of PHP. At the same time, I want my HTML to be legible. When you look at it, that's kind of a problem, though... for instance (assume this had some PHP in the middle, and there was actually a reason not to just put this in HTML in the first place): Simple PHP: ?php echo 'html'; echo 'head'; echo ' titlePage Title/title'; echo '/head'; echo 'body'; echo 'pThis is the page body/p'; echo '/body'; echo '/html'; ? Output page source: htmlhead titlePage Title/title/headbodypThis is the page body/p/body/html Now, I can go through and add a newline to the end of each line (echo 'html' . \n; and so on), but it adds a lot of typing. Is there a way to make this happen automatically? I thought about just building a simple function, but I run into problem with quotes -- either I can't use single quotes, or I can't use double quotes. Historically, I've dealt with the issue by just having ugly output code, but I'd like to stop doing that. How do other people deal with this? Thanks, Alex Alex Just add a \n at the end as echo 'html\n'; That will not work. Single quotes means that the '\n' is not interpreted as a new line so you'll see a bunch of '\n' in the output. What I sometimes do is: $out = array(); $out[] = 'html'; $out[] = 'head'; $out[] = ' titlePage Title/title'; $out[] = '/head'; $out[] = 'body'; $out[] = 'pThis is the page body/p'; $out[] = '/body'; $out[] = '/html'; echo join(\n,$out); -- Act as if you were already happy and that will tend to make you happy. -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime()
On my home machine running 5.3.2-2 in debian linux the commands: echo date('Y-m-d',strtotime('first day of this month')).'br/'; echo date('Y-m-d',strtotime('last day of next month')); give the expected results. I just got setup with a hosting provider running 5.2.13 on BSD and both give '1969-12-31'. What could be causing this? The second command is straight from the manual and the first is clearly implied. So far everything else seems to work as expected. -- Economics is extremely useful as a form of employment for economists. -- John Kenneth Galbraith Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime()
On Mon, Aug 23, 2010 at 05:57:28PM -0400, Daniel Brown wrote: On Mon, Aug 23, 2010 at 17:02, Ashley Sheridan a...@ashleysheridan.co.uk wrote: The example you quote as being straight from the manual page is actually from the user-submitted code snippets, and I can't find the documentation to support it. I can only assume that it's possibly an experimental thing, or something that shouldn't work but by freak coincidence does occasionally. Maybe use mktime() instead to get the dates? Relative date strings - specifically including those terms - are in PHP5 = 5.3.0 exclusively, for now. I don't believe there are any plans to backport it to the 5.2 branch. Rick, if you want to add this as a Documentation Problem to http://bugs.php.net/, one of us will likely add it to the documentation, as it probably should not only be noted, but also be in an easy-to-find place (you know, such as right there on the strtotime() manual entry). After I sent my original post the one and only user comment on the relative date strings man page was pointed out to me. So, it's there but how many people make a habit of reading all the user comments? Anyway, the following work: // first day of this month $t1 = strtotime(date('Y-m',strtotime('this month'))); // last day of next month // get the first day of month after next and subtract one day $t2 = strtotime(date('Y-m',$t1 + (86400 * 70)))-86400; -- I'm so optimistic I'd go after Moby Dick in a row boat and take the tartar sauce with me. -- Zig Zigler Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime()
On Mon, Aug 23, 2010 at 11:38:41PM -0400, Daniel P. Brown wrote: On Mon, Aug 23, 2010 at 22:27, Rick Pasotto r...@niof.net wrote: After I sent my original post the one and only user comment on the relative date strings man page was pointed out to me. So, it's there but how many people make a habit of reading all the user comments? A few thousand per day, give or take. I do remember seeing which page had the note, but I don't recall which one. Can you send me the link so that I can pop that out and put the info in the documentation? http://us2.php.net/manual/en/datetime.formats.relative.php -- There are always three speeches, for every one you actually gave. The one you practiced, the one you gave, and the one you wish you gave. -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML in emails
On Sun, Jul 04, 2010 at 06:31:38PM +0200, Per Jessen wrote: Al wrote: I know this is a bit off-topic; but close enough. I'm starting to update the email feature of one of my DB applications and noticed that it appears most of the fancy emails I receive are using just plain old, simple html pages, with a note about not being able to see, go here with a link. Such emails are stupid. Obviously I can read the email quite fine. The problem is that there is no useful content. Just an instruction to click on a link. It use to be that we specified content-type text/html, etc. and sent both the plain ASCII and the html with boundaries and so forth. Yes, multipart/alternative that was. Seems like, from my preliminary Google searching, I should not waste time with the standard's way and just go straight to sending simple html pages since all modern browsers handle it well. And, it appears to be the way web is going. Then I will never read your email. Browsers are for web pages, not email. What are you folks doing? We follow the standard and send both text and html. The text portion is the *only* portion I read. -- When dealing with people, remember you are not dealing with creatures of logic, but creatures of emotion. -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function within a class function
Within a class function I have defined another function for use with the usort() function. How do I reference it? When it's not part of a class usort($arr,cmp) works fine but when it's within a class function I get this error: PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION Is it not in the scope of the class function? -- Memory is like an orgasm. It's a lot better if you don't have to fake it. -- Seymour Cray (on virtual memory) Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function within a class function
On Sun, Jun 20, 2010 at 08:47:53PM -0400, Brandon Rampersad wrote: $this-usort(); self::usort(); On Sun, Jun 20, 2010 at 7:45 PM, Rick Pasotto r...@niof.net wrote: Within a class function I have defined another function for use with the usort() function. How do I reference it? When it's not part of a class usort($arr,cmp) works fine but when it's within a class function I get this error: PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION Is it not in the scope of the class function? Forgive my ignorance but I have absolutely no idea what you're trying to tell me. usort() is part of the language so when, why, how does it become an object of some class? -- We have rights, as individuals, to give as much of our own money as we please to charity; but as members of Congress we have no right so to appropriate a dollar of public money. -- David Crockett Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] not receiving mail from list
This evening I sent two emails to the list but have not received either of them back. Checking my logs I see that the last email I got was dated 2010-06-12. Could I have been unsubscribed without my knowing about it? (My posts were received by the list since I got private replies.) -- ...He who laughs does not believe in what he laughs at, but neither does he hate it. Therefore, laughing at evil means not preparing oneself to combat it, and laughing at good means denying the power through which good is self-propagating. -- Umberto Eco, The Name of the Rose Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-cli
Has cli php changed recently? I've got a php script (script1) that creates a php script (script2) by opening a file and then writing to it. When I try to run it from the command line script1 is simply copied to stdout. When I run it from the browser it works as expected. The directory has 777 permissions so that should not be the problem. Any ideas? -- Whatever the immediate gains and losses, the dangers to our safety arising from political suppression are always greater than the dangers to that safety resulting from political freedom. Suppression is always foolish. Freedom is always wise. -- Alexander Meiklejohn, 1955 Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: Has cli php changed recently? I've got a php script (script1) that creates a php script (script2) by opening a file and then writing to it. When I try to run it from the command line script1 is simply copied to stdout. When I run it from the browser it works as expected. The directory has 777 permissions so that should not be the problem. Any ideas? How are you running it from the command line? Is there more than one way? I suppose with and without the -f could count as two ways, but the man page says without defaults to with so they're really the same. -- Remember, today is the tomorrow you worried about yesterday. -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: Has cli php changed recently? I've got a php script (script1) that creates a php script (script2) by opening a file and then writing to it. When I try to run it from the command line script1 is simply copied to stdout. When I run it from the browser it works as expected. The directory has 777 permissions so that should not be the problem. Any ideas? How are you running it from the command line? Is there more than one way? I suppose with and without the -f could count as two ways, but the man page says without defaults to with so they're really the same. Well you havn't given an example, and just say you're calling the script from command line and it's outputting the script there. Are you maybe just calling the php file without calling php first? Of course not. php scripts are not executable. If I had tried to execute it directly the shell would have told me that. If I had then set the executable bit the shell would have tried to execute the contents of the file and the shell would have given several error messages. I repeat: is there more than one way to run a php script from the cli? -- Feeling sorry for yourself, and you present condition, is not only a waste of energy but the worst habit you could possibly have. -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: Rick Pasotto wrote: I repeat: is there more than one way to run a php script from the cli? On *nix, you can add #!/usr/bin/php as first line and make file executable (chmod +x). Functionally the same. php is still interpreting the script. The script is still not an executable. And, of course, the results are the same. The problem is that php is *not* interpreting the script. It's acting like 'cat'. -- There are two tragedies in life. One is to lose your heart's desire. The other is to gain it. -- George Bernard Shaw Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Mon, Mar 15, 2010 at 02:35:54PM +1300, Dmitry Ruban wrote: Rick Pasotto wrote: On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: Rick Pasotto wrote: I repeat: is there more than one way to run a php script from the cli? On *nix, you can add #!/usr/bin/php as first line and make file executable (chmod +x). Functionally the same. php is still interpreting the script. The script is still not an executable. And, of course, the results are the same. The problem is that php is *not* interpreting the script. It's acting like 'cat'. It sounds like you may use short tags ? and short_open_tag is off in your cli php.ini Thank you. That was the problem. Looks like I've got a habit to change and a lot of file maintenance to do. -- There are two tragedies in life. One is to lose your heart's desire. The other is to gain it. -- George Bernard Shaw Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which query is more correct?
On Fri, Nov 20, 2009 at 04:41:58PM -0600, LAMP wrote: Hi, I need to pull all records from the table Registrants they are NOT in the table ToBeRecleared Registrants.Reg_ID is PK ToBeRecleared.tbrc_Reg_ID is PK Which query is more correct? SELECT r.* FROM registrants r where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM toberecleared) SELECT r.* FROM registrants r where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where tbrc_reg_id=r.reg_id) = 0 I checked explain of bot queries - but can't read them. :-) SELECT t1.* FROM registrants t1 LEFT JOIN ToBeRecleared t2 on t1.reg_id = t2.tbrc_reg_id where t2.tbrc_reg_id is NULL -- Every major horror of history was committed in the name of an altruistic motive. -- Ayn Rand, The Fountainhead, 1943 Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script sometimes not recognized as php
I have several LAMP sites on my machine. Occasionally when accessing a page the browser says the document is of unknown type and wants to know what to do with it. I click on 'Cancel' and try the page again and this time it works as it should. Why would apache *sometimes* fail to interpret a php script as php? -- The difficulties which I meet with in order to realize my existence are precisely what awaken and mobilize my activities, my capacities. Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mail() is duplicating
I have several forms on my site that use the same sequence of events: The first script displays and validates the form data, the second reformats and asks for confirmation or editing, and the third script sends the data in an email to the relevent people. Two of these forms work exactly as they're supposed to but the third sends duplicate emails to everyone. I have looked and looked and I've run diff and I can see no reason why this should be happening. Could someone suggest what I might have wrong? -- The notion that a radical is one who hates his country is naive and usually idiotic. He is, more likely, one who likes his country more than the rest of us, and is thus more disturbed than the rest of us when he sees it debauched. He is not a bad citizen turning to crime; he is a good citizen driven to despair. --- H. L. Mencken Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] system() Question
On Sun, Dec 28, 2008 at 12:40 PM, Ryan O'Sullivan r...@rynet.com wrote: Hello all, I am using system to convert some files using a binary in linux. My code looks like this: $response = system('gpsbabel -p -r -t -i gpx -f test.gpx -o kml -F test2.kml', $retval); echo pResponse: , $response, /ppReturn Value: , $retval; The $retval is returning code 127 - Any ideas on why this? You overlooked the ampersand in front of $retval. The syntax for 'system' is: string system ( string $command [, int $return_var ] ) You have to pass a pointer to the variable, not the variable itself. -- Paper has a genius for multiplication that cannot be equaled anywhere else in nature. -- Hugh Keenleyside Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request to bash/jump/screw my code
On Mon, Dec 08, 2008 at 09:01:56AM -0800, Ryan S wrote: Any advise is also most welcome. 'Advise' is a verb. 'Advice' is a noun. No charge. -- I didn't understand this at first, but YOUR CONVINCING USE OF CAPITAL LETTERS HAS MADE IT ALL CLEAR TO ME. -- J. Nairn Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request to bash/jump/screw my code
On Mon, Dec 08, 2008 at 09:01:56AM -0800, Ryan S wrote: Hello everyone, Recently I worked on a rather decent sized project and it just went live yesterday. We cannot really afford a security specialist so would appreciate it if you could hit our site with whatever you want to (just dont take us offline with something like a DDOS please) and tell us if you find any problems. As we cannot afford to pay you for this service all we an say is thank you if you decide to give this a go with a few seconds or a few minutes of your time. It should be fun though as its a jokes section and even has funny images/cartoons and funny vids. The site is at http://ezee.se/funnies/index.php validator.w3.org found 109 errors and 69 warnings on the front page. http://ezee.se/funnies/show_funny.php?id=p88sec=1 has: Posted by: \' OR id != \' On: 2008-12-08 13:24:59 \' OR id != \' -- The greatest danger to liberty today comes from...expert administrators exclusively concerned with what they regard as the public good. -- Friedrich Hayek Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
On Sun, Dec 07, 2008 at 10:03:26AM -0500, tedd wrote: Hi gang: I just interviewed for a job teaching at the local college (imagine me taking minds of mush and molding them to the world according to tedd -- frightening huh?) In any event, the interviewer asked me how long I've been using MySQL and I replied several years. After which she asked a single question, which was What does EXIST mean? Now without running to the manuals, please be honest and tell me how many of you know off the top of your head what EXIST means? I would be curious to know. I answered the question correctly, (I'm one of those weird types who read manuals for fun) but I have never used EXIST in a query. Have any of you? Really? What *does* it mean? It's not in the manual index. Perhaps you're confusing it with EXISTS. And while we're on the subject of MySQL -- while we all know how to write it, how do you say it? I've read that the common way is to say My Squell, or something like that. But I always sounded out each letter, such as My S-Q-L. The interviewer pronounced it the same as I, but I have heard others say it differently. My-S-Q-L. Few people realize that 'sequel' was the language used by Ingres for their database and it was different from S-Q-L. -- You are the only one who can use your ability. It is an awesome responsibility. -- Zig Zigler Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Form Loop
On Sat, Oct 18, 2008 at 08:07:26PM -0500, Shawn McKenzie wrote: Terry J Daichendt wrote: I'm trying to create a form with a loop. I need to append a value to a field name each time through the loop. For Instance: while ($row = mysql_fetch_assoc($result)) { $x=1; echo tr;echo tdinput type='text' id='qty' name='quantity_' size='2' value='$row[qty]' //td; echo /tr; $x++; } the name value quantity needs the value of x appended to it. quantity_1, quantity_2 etc. What is the correct syntax to achieve this, especially the parsing to get it to work. I suspect the dot operator to append it but I can't get the parsing down. Terry Daichendt echo 'tdinput type=text id=qty name=quantity_' . $x . ' size=2 value=' . $row['qty']. ' //td'; However, I would use an array: echo 'tdinput type=text id=qty name=quantity[' . $x . '] size=2 value=' . $row['qty']. ' //td'; Depending upon your use, you can even leave out the index and let it increment. echo 'tdinput type=text id=qty name=quantity[] size=2 value=' . $row['qty']. ' //td'; Ids must be unique within a document. -- We may eventually come to realize that chastity is no more a virtue than malnutrition. -- Alexander Comfort Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] when mysql is down
Today my hosting company took down the mysql server for about 1/2 hour. As a result some php errors displayed. All of my pages have a random quote from a mysql table. If it's not available it's really not a big deal. However, some of the pages depend entirely on data from the database. What's the best way to handle this? If the mysql is required should I redirect to the front page (which doesn't need mysql except for the quote) or show a blank (or error message) content area (navigation would still be available as it's the same on all pages)? The quote is from an include file. What's the best way to output nothing if the mysql connection fails? I realize these are probably elementary questions but any advice would be appreciated. -- ... the state ... is not armed with superior honesty, but with superior physical strength. -- Henry David Thoreau Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] where to put a function
Probably been answered a thousand times; if so, just tell me where to look. I have a function that includes a specific sql query that is used on only one page on the site. Should that function be coded (1) in the page itself, (2) in a separate file that only that page includes, or (3) in a master file that contains all the functions used on the site and is included on every page? I've been doing #1 (not actually a function in this case) but #3 is appealing, especially since I would implement it as OOP and the page itself would be really just a template. What is the cost of parsing a bunch of functions that are not used on a given page load? -- If some peoples pretend that history or geography gives them the right to subjugate other races, nations, or peoples, there can be no peace. -- Ludwig von Mises Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question about one php script passing control to another
On Thu, Mar 20, 2008 at 12:08:39PM -0400, Rod Clay wrote: Hello. I am new to php programming, but have spent many years programming in many other languages, most recently perl (with which php seems to have much in common!). In every other language I've worked with there is a way for one program to pass control to another. However, so far in all of the books and other documentation I've looked at for php, I cannot find a way for one php program to pass control to another. Is this possible in php, and, if so, please let me know how. Thank you. This may be what you are looking for: include('next_program'); exit(); If you do this, you have to keep in mind that all the variables you set in the first program are *still* set in the second. This is useful when your first program needs to choose which of two or more programs to run next depending on its calculations. For example, if your first program does error checking then it might want to run an all_ok program or an edit program. -- To be without a plan is the true genius and glory of the antislavery movement. The mission of that movement is to preach eternal truths, and to bear witness to everlasting testimony against the giant falsehoods which bewitch and enslave the land. -- Nathaniel Peabody Rogers Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Why does the host make a difference?
I have a routine that uses the PEAR module CRYPT_BLOWFISH to encrypt a value and then base64_encode() to create a printable string. If I reverse the process on the same host I get the orginal value however if I do the reverse processing on a different host the result is garbage. Shouldn't both the encryption and the encoding/decoding be host independent? Aren't both routines standard, public algorithms that should be reversable even between different operating systems? That's not my case since both are linux but one is php4 and the other php5. If that's the problem, why? -- There are two tragedies in life. One is to lose your heart's desire. The other is to gain it. -- George Bernard Shaw Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pear
It is quite possible (ie, I've done it) to install the PEAR modules you need within your own web space. You just have to get the directory structure and your include line right. The PEAR system is just a bunch of php files so if you've got php you've got all you really need. -- ... most legislators ... as they rarely make any moral distinctions, they are as likely to serve the devil, without intending it, as God. -- Henry David Thoreau Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking for and enforcing https
On Tue, Feb 26, 2008 at 04:46:38PM -0500, Daniel Brown wrote: Of course, getting into that is a completely different discussion from the post made by the OP whom, as it appears, gave up and took off when Tedd *hijacked* his thread. ;-P No, I've been reading all the posts and have learned and implemented. Works great. I've had nothing to add although I've been somewhat annoyed by the excessive quoting. -- The most important thing in life is not simply to capitalize on your gains. Any fool can do that. The important thing is to profit from your losses. That requires intelligence, and makes the difference between a man of sense and a fool. -- Dale Carnegie Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] checking for and enforcing https
What is the best or recomended proceedure for making sure that a page is accessed only via a secure connection? -- The secret of being miserable is to have the leisure to bother about whether you are happy or not. The cure is occupation. -- George Bernard Shaw Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explorer
On Sat, Nov 10, 2007 at 09:33:17AM -0500, Bastien Koert wrote: on the local machine? no. you can simulate an explorer for files on the server An input type=file will automatically display a browse button that opens a user environment specific file browser (aka explorer). -- Market-like arrangements ... reduce the need for compassion, patriotism, brotherly love, and cultural solidarity as motivating forces. Harnessing the base motive of material self-interest ... is perhaps the most important social invention mankind has achieved. -- C. L. Schulte, Public Use of the Private Interest, 1977 Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding next recored in a array
On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote: Richard Kurth wrote: $Campaign_array| = array('0','1','3','5','8','15','25');| I know that I can find the next recored in a array using next. What I do not understand is if I know the last number was say 5 how do I tell the script that that is the current number so I can select the next record || I think you'll need your own function for this. Nope. Just use array_search(). $k = array_search('5',$Campaign_array); if ($k + 1 count($Campaign_array)) { echo $Campaign_array[$k + 1]; } Pass in the array and loop through it until you find the key, increment that, ensure that there is another value with that key, and return the key (or the value). (untested) function nextInArray($arr, $val) { $next_key = NULL; for ($i = 0; $i sizeof($arr);$i++) { if ($arr[$i] == $val) { $next_key = ++$i; break; } } // return the key: return (array_key_exists($next_key) ? $next_key : NULL); // or the value: return (array_key_exists($next_key) ? $arr[$next_key] : NULL); } However, in your example, you're searching for the key that points to the value '5'. What if the value '5' occurs more than once? From the docs: If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_keys() with the optional search_value parameter instead. -- Now what liberty can there be where property is taken without consent?? -- Samuel Adams Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding next recored in a array
On Sun, Sep 16, 2007 at 06:04:45PM -0700, Richard Kurth wrote: Richard Kurth wrote: Rick Pasotto wrote: On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote: Richard Kurth wrote: $Campaign_array| = array('0','1','3','5','8','15','25');| I know that I can find the next recored in a array using next. What I do not understand is if I know the last number was say 5 how do I tell the script that that is the current number so I can select the next record || I think you'll need your own function for this. Nope. Just use array_search(). $k = array_search('5',$Campaign_array); if ($k + 1 count($Campaign_array)) { echo $Campaign_array[$k + 1]; } I tried this and it gives me nothing back. It should give me a 8 $Campaign_array= array('0','1','3','5','8','15','25'); $val=5; $k = array_search($val,$Campaign_array); if ($k + 1 count($Campaign_array)) { echo $Campaign_array[$k + 1]; } I figured out way it was not working $k + 1 count needed to be $k + 1 count Yup. Sorry 'bout that. But now it works perfect -- Our fatigue is often caused not by work, but by worry, frustration and resentment. -- Dale Carnegie Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string as file
On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote: Rick Pasotto wrote: On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote: On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote: Does php have a facility similar to python's stringIO? What I'm wanting to do is similar to a mail merge. IOW, I know I can create an include file like: $out = EOT This is an example of $var1 and $var2. EOT; and then after assigning values to $var1 and $var2 include that file. I can later use different values for $var1 and $var2 and get a different $out with a second include. eval() Explain. One word responses really don't do any good. Exactly *what* would be the argument to eval()? RTFM, that's what it's there for. I did. That's why I rejected the use of eval() before I posted the message. eval() is totally unsuitable for what I want. Unless, that is, you or Greg can explain how using eval() will get me what I want. I think that neither you nor Greg understands what I'm looking for. Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion. Incidentally, eval is evil and potentially a giant security hole. You'd be better off doing replacements with preg_match rather than executing a string. Agreed. That's another reason I had already rejected it. Although in this case, since I would have full control of all the variables, it would probably be ok. -- Whatever crushes individuality is despotism, by whatever name it may be called. -- John Stuart Mill, 1859 Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string as file
On Thu, Aug 09, 2007 at 02:39:51PM -0700, Jim Lucas wrote: Rick Pasotto wrote: Does php have a facility similar to python's stringIO? What I'm wanting to do is similar to a mail merge. IOW, I know I can create an include file like: $out = EOT This is an example of $var1 and $var2. EOT; and then after assigning values to $var1 and $var2 include that file. I can later use different values for $var1 and $var2 and get a different $out with a second include. Can I someout include a string instead of a file? Or maybe there is some completely different way to do what I want. template.php ?php ob_start(); echo Hi, my name is {$first_name} {$last_name}.; return ob_get_clean(); ? This is two different ways you can do it, bases on your input data array structure test.php ?php $values = array(); $values[] = array('first_name' = 'Jim','last_name' = 'Lucas'); $values[] = array('first_name' = 'James','last_name' = 'Lucas'); $values[] = array('first_name' = 'Jimmy','last_name' = 'Lucas'); foreach ($values AS $row) { extract($row); echo include 'template.php'; } $values = array(); $values[] = array('Jim','Lucas'); $values[] = array('James','Lucas'); $values[] = array('Jimmy','Lucas'); list($first_name, $last_name) = current($values); do { echo include 'template.php'; } while (list($first_name, $last_name) = next($values)); ? You have misunderstood. You are still putting the template in an external file. I want it in the main file. I don't want to maintain two different files. -- It is always from a minority acting in ways different from what the majority would prescribe that the majority in the end learns to do better. -- Friedrich Hayek Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string as file
On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote: On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote: Does php have a facility similar to python's stringIO? What I'm wanting to do is similar to a mail merge. IOW, I know I can create an include file like: $out = EOT This is an example of $var1 and $var2. EOT; and then after assigning values to $var1 and $var2 include that file. I can later use different values for $var1 and $var2 and get a different $out with a second include. eval() Explain. One word responses really don't do any good. Exactly *what* would be the argument to eval()? -- In vices, the very essence of crime -- that is, the design to injure the person or property of another -- is wanting. It is a maxim of law that there can be no crime without a criminal intent. -- Lysander Spooner Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] string as file
Does php have a facility similar to python's stringIO? What I'm wanting to do is similar to a mail merge. IOW, I know I can create an include file like: $out = EOT This is an example of $var1 and $var2. EOT; and then after assigning values to $var1 and $var2 include that file. I can later use different values for $var1 and $var2 and get a different $out with a second include. Can I someout include a string instead of a file? Or maybe there is some completely different way to do what I want. -- I have always in my own thought summed up individual liberty, and business liberty, and every other kind of liberty, in the phrase that is common in the sporting world, A free field and no favor. -- Woodrow Wilson, U.S. President, 1915 Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_replace() help
I have quotes like the following: $txt = 'A promise is a debt. -- Irish Proverb'; I'd like to replace all the spaces afer the '--' with nbsp; This is what I've tried: $pat = '/( --.*)(\s|\n)/U'; $rpl = '$1$2nbsp;'; while (preg_match($pat,$txt,$matches) 0) { print $txt\n; printf([0]: %s\n,$matches[0]); printf([1]: %s\n,$matches[1]); printf([2]: %s\n,$matches[2]); preg_replace($pat,$rpl,$txt); } The prints are for debugging. $matches contains what I expect but nothing gets replaced and $txt stays the same so it loops forever. What am I doing wrong? -- Everyone is as God has made him, and oftentimes a great deal worse. -- Miguel De Cervantes Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] triming utf8 (?) a string
On Sun, Jul 08, 2007 at 06:30:54PM -0700, Jim Lucas wrote: Rick Pasotto wrote: I'm using the PEAR Crypt_Blowfish module. When I decrypt the encrypted string the result is the original plus some '\ufffd' bytes. How can I get rid of those extra bytes? I've tried both trim($x,'\ufffd') and trim($x,utf8_decode('\ufffd')). trim() is meant to remove chars from the beginning and ending of a string. http://us2.php.net/str_replace is meant to remove a set of chars from a string. Anywhere within the string. But it *is* a single char that I'm wanting to remove (multiple times). Perhaps you are confusing a char with a byte? Anyway, the problem is solved from the other end. So long as the original string has a length that is a multiple of 8 the encoded/decoded result has no extra chars. Padding the initial string with spaces makes it easy to then trim() the output. -- The care of every man's soul belongs to himself. But what if he neglect the care of it? Well what if he neglect the care of his health or his estate, which would more nearly relate to the state. Will the magistrate make a law that he not be poor or sick? Laws provide against injury from others; but not from ourselves. God himself will not save men against their wills. -- Thomas Jefferson 1776-10 Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] triming utf8 (?) a string
On Mon, Jul 09, 2007 at 07:45:10AM -0700, Jim Lucas wrote: Rick Pasotto wrote: On Sun, Jul 08, 2007 at 06:30:54PM -0700, Jim Lucas wrote: Rick Pasotto wrote: I'm using the PEAR Crypt_Blowfish module. When I decrypt the encrypted string the result is the original plus some '\ufffd' bytes. How can I get rid of those extra bytes? I've tried both trim($x,'\ufffd') and trim($x,utf8_decode('\ufffd')). trim() is meant to remove chars from the beginning and ending of a string. http://us2.php.net/str_replace is meant to remove a set of chars from a string. Anywhere within the string. But it *is* a single char that I'm wanting to remove (multiple times). Perhaps you are confusing a char with a byte? Nope, not confused, but I ASSUMED that maybe the chars were not at the beginning or ending of the string, but somewhere in the middle. ( you didn't say where the chars were ) Yes, I did. the original *plus* some '\ufffd' bytes clearly means that they were added at the end. And since you were using trim(), that you were using the wrong function. Which only works on the beginning and ending of a string. I wanted to remove the characters that were added at the *end* of the string. -- Blaming 'society' makes it awfully easy for a person of weak character to shrug off his own responsibility for his actions. -- Stanley Schmidt Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] triming utf8 (?) a string
I'm using the PEAR Crypt_Blowfish module. When I decrypt the encrypted string the result is the original plus some '\ufffd' bytes. How can I get rid of those extra bytes? I've tried both trim($x,'\ufffd') and trim($x,utf8_decode('\ufffd')). -- Economics is extremely useful as a form of employment for economists. -- John Kenneth Galbraith Rick Pasotto[EMAIL PROTECTED]http://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php