php-general Digest 29 Aug 2009 13:06:00 -0000 Issue 6312
php-general Digest 29 Aug 2009 13:06:00 - Issue 6312 Topics (messages 297453 through 297472): Re: Problem outputting MySQL Date field 297453 by: Jim Lucas Re: [PHP-WIN] Re: [PHP] Problem outputting MySQL Date field 297454 by: Keith Davis 297455 by: John Meyer Re: Best way to test for form submission? 297456 by: Keith 297459 by: J DeBord 297463 by: Nisse Engström 297466 by: Warren Vail 297467 by: O. Lavell 297472 by: tedd Re: Error when execute header('location: otherpage.php') after email been sent out. Any Workaround? 297457 by: Keith Re: Some body test php6-dev version for mbs? 297458 by: hack988 hack988 Re: Converting URL's to hyperlinks. 297460 by: Eric Re: File Open Prompt? 297461 by: Ralph Deffke 297462 by: Ashley Sheridan 297464 by: Ralph Deffke 297468 by: Eric 297469 by: Eric Re: Calling extension function from another 297465 by: leledumbo 297470 by: J DeBord 297471 by: Stuart Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- John Meyer wrote: Devendra Jadhav wrote: No need to do anything special. It should display date as string. Can you provide little more information or code snippet? $tweettable .= preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', 'a href=$1$1/a',$row[TWEET_TEXT]) . br . Sent at: . $rowqry[TWEET_CREATEDAT]; $tweettable .= brSent Using: . $row[TWEET_CREATEDBY] . /td/tr; And I checked the database. The date is there. Two things jump out. 1. TWEET_CREATEDAT is that suppose to be TWEET_CREATEDATE ?? 2. two variables are accessed from the $row array, but the third is referenced from the $rowqry array. This begs the question: Which is it? $row or $rowqry ? Try this $tweettable .= preg_replace( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', 'a href=$1$1/a', $row[TWEET_TEXT]); $tweettable .= 'br /Sent at: ' . $row[TWEET_CREATEDATE]; $tweettable .= 'br /Sent Using: {$row['TWEET_CREATEDBY']}/td/tr; -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare ---End Message--- ---BeginMessage--- But how are you getting the data from the db? Does $rowqry represent a call using the mysql_fetch_array() function? Sent from my magic iPhone, Keith Davis 214-906-5183 On Aug 28, 2009, at 7:39 PM, John Meyer johnme...@pueblocomputing.com wrote: Devendra Jadhav wrote: No need to do anything special. It should display date as string. Can you provide little more information or code snippet? $tweettable .= preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.] *(\?\S+)?)?)?)@', 'a href=$1$1/a',$row[TWEET_TEXT]) . br . Sent at: . $rowqry[TWEET_CREATEDAT]; $tweettable .= brSent Using: . $row[TWEET_CREATEDBY] . /td/tr; And I checked the database. The date is there. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This message (including any attachments) may contain confidential or otherwise privileged information and is intended only for the individual(s) to which it is addressed. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or that arise as a result of e-mail transmission. If verification is required please request a hard-copy version from the sender. www.pridedallas.com ---End Message--- ---BeginMessage--- Keith Davis wrote: But how are you getting the data from the db? Does $rowqry represent a call using the mysql_fetch_array() function? mysql_fetch_assoc() ---End Message--- ---BeginMessage--- I've encountered issue with checking $_POST['submit'] if(isset($_POST['submit'])) {} If the form consists of checkbox/radio and text field, some of my forms can be submitted by just press [ENTER] at the end of one of the text field. In this case, the $_POST['submit'] is set even the submit button was not clicked. However, in some of my forms, $_POST['submit'] will not be set if I submit the form by pressing [ENTER] in one of the text field. So, if the later case
Re: [PHP] Re: Best way to test for form submission?
I've heard stories like this before, but never encountered it myself. I forgot to mention that it is a good idea to give your submit buttons a value attribute. Regardless of how the form is submitted, you should then have a value for ['submit']. Reminding the user that they must do anything other than the simplest things is usually not a good approach. There will inevitably be users who do not see/follow your reminder and use the enter button. Give the submit button a value. On Sat, Aug 29, 2009 at 6:50 AM, Keith survivor_...@hotmail.com wrote: I've encountered issue with checking $_POST['submit'] if(isset($_POST['submit'])) {} If the form consists of checkbox/radio and text field, some of my forms can be submitted by just press [ENTER] at the end of one of the text field. In this case, the $_POST['submit'] is set even the submit button was not clicked. However, in some of my forms, $_POST['submit'] will not be set if I submit the form by pressing [ENTER] in one of the text field. So, if the later case happen, I need to remind the user to explicitly click the [Submit] button. I don't know why or in what condition that pressing [ENTER] will not submit the whole form include the $_POST['submit']. Keith Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1251467419.27899.106.ca...@localhost... On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote: On 08/27/2009 11:09 PM, Adam Jimerson wrote: This question might give away the fact that I am a php noob, but I am looking for the best way to test for form submission in PHP. I know in Perl this can be done with if (param) but I don't know if that will work with PHP. I have read the Learning PHP 5 book and the only thing that was mentioned in the book was the use of something like this print pHello .$_POST['username']./p; Sorry copied and pasted the wrong line (long day) if (array_key_exists('username',$_POST)) I'm sure that this is not the best/recommended way to do this but I'm hoping someone here will point me in the right direction. The best way I've found is to do something like this: if(isset($_POST['submit'])) {} Note that in-place of submit you can put the name of any form element. I chose submit here, because every form should have a submit button. Note also that this will only work if you have given your submit button a name: input type=submit name=submit value=Submit/ Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
- Original Message - From: John Meyer johnme...@pueblocomputing.com To: php-general@lists.php.net Sent: Friday, August 28, 2009 1:56 AM Subject: [PHP] Converting URL's to hyperlinks. What sort of function would I need if I wanted to convert those URLs from plain jane text? You should encode the url before printing as usual way $url = htmlentities('http://www.mysite.com/index.php?act=1t=10'); echo a href=\{$url}\mysite/a; - Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Open Prompt?
are u shure, u dont send anything out before u send the headers? even one space would be too much. ralph_def...@yahoo.de Dan Shirah mrsqua...@gmail.com wrote in message news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com... You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Open Prompt?
On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote: are u shure, u dont send anything out before u send the headers? even one space would be too much. ralph_def...@yahoo.de Dan Shirah mrsqua...@gmail.com wrote in message news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com... You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box. Try putting all of that inside of a headers_sent(){} block. If nothing is displayed, it means that you've already sent something to the browser, so the headers have already been sent and the extra ones you are sending do nothing. This sort of thing is shown in your error log also. If you still get the tif displayed as text, then are you sure that the tif is valid? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Best way to test for form submission?
On Sat, 29 Aug 2009 12:50:41 +0800, Keith wrote: I don't know why or in what condition that pressing [ENTER] will not submit the whole form include the $_POST['submit']. http://www.alanflavell.org.uk/www/formquestion.html http://www.alanflavell.org.uk/www/#Tips /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Open Prompt?
even the .tif is valid or not, the file should be downloaded Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1251530173.27899.135.ca...@localhost... On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote: are u shure, u dont send anything out before u send the headers? even one space would be too much. ralph_def...@yahoo.de Dan Shirah mrsqua...@gmail.com wrote in message news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com... You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box. Try putting all of that inside of a headers_sent(){} block. If nothing is displayed, it means that you've already sent something to the browser, so the headers have already been sent and the extra ones you are sending do nothing. This sort of thing is shown in your error log also. If you still get the tif displayed as text, then are you sure that the tif is valid? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling extension function from another
extension A has function a, extension B has function b. How can I make b calls a? -- View this message in context: http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25200892.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Best way to test for form submission?
To test a form I usually send the form contents to a php file that contains the following; foreach($_POST as $nm = $val) echo _POST[.$nm.] [.$val.]br; foreach($_GET as $nm = $val) echo _GET[.$nm.] [.$val.]br; Checkboxes and radio buttons only send their value if the control is checked. You can have multiple submit buttons (type=submit) on a form, but you should assign them different name parameters to recognize which one is clicked (any one of them will cause the form to be submitted, but the only one that will establish a $_POST entry named submit is the submit control that is named submit (name=submit). Pressing enter is not sensed by most controls. Most browsers will look at the field the cursor is positioned on when enter is pressed, and if it is not one of the controls that response to an enter, it scans the DOM (list of controls), and will apply the enter to the first control that responds to an enter, most common is the type=submit control. If a select control is between the text box and the submit button (in the DOM list) the current entry for the select list will be selected and the form will not be submitted unless the list includes a onChange=this.form.submit(); javascript entry. Be careful designing forms that are dependent on some of these behaviors, like positioning a submit button to the right of a text box to intentionally receive the enter, because different browsers will probably behave differently. Hope this helps a bit. Warren Vail Vail Systems Technology -Original Message- From: Keith [mailto:survivor_...@hotmail.com] Sent: Friday, August 28, 2009 9:51 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: Best way to test for form submission? I've encountered issue with checking $_POST['submit'] if(isset($_POST['submit'])) {} If the form consists of checkbox/radio and text field, some of my forms can be submitted by just press [ENTER] at the end of one of the text field. In this case, the $_POST['submit'] is set even the submit button was not clicked. However, in some of my forms, $_POST['submit'] will not be set if I submit the form by pressing [ENTER] in one of the text field. So, if the later case happen, I need to remind the user to explicitly click the [Submit] button. I don't know why or in what condition that pressing [ENTER] will not submit the whole form include the $_POST['submit']. Keith Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1251467419.27899.106.ca...@localhost... On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote: On 08/27/2009 11:09 PM, Adam Jimerson wrote: This question might give away the fact that I am a php noob, but I am looking for the best way to test for form submission in PHP. I know in Perl this can be done with if (param) but I don't know if that will work with PHP. I have read the Learning PHP 5 book and the only thing that was mentioned in the book was the use of something like this print pHello .$_POST['username']./p; Sorry copied and pasted the wrong line (long day) if (array_key_exists('username',$_POST)) I'm sure that this is not the best/recommended way to do this but I'm hoping someone here will point me in the right direction. The best way I've found is to do something like this: if(isset($_POST['submit'])) {} Note that in-place of submit you can put the name of any form element. I chose submit here, because every form should have a submit button. Note also that this will only work if you have given your submit button a name: input type=submit name=submit value=Submit/ Thanks, Ash http://www.ashleysheridan.co.uk -- 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] Re: Best way to test for form submission?
Shawn McKenzie wrote: Adam Jimerson wrote: This question might give away the fact that I am a php noob, but I am looking for the best way to test for form submission in PHP. [..] Just to throw it into the mix: if(!empty($_POST)) for a general test of whether any form was posted. There are more methods, I always use: if($_SERVER[REQUEST_METHOD] == POST) { do_something(); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Open Prompt?
- Original Message - From: Ashley Sheridan a...@ashleysheridan.co.uk To: Ralph Deffke ralph_def...@yahoo.de Cc: php-general@lists.php.net Sent: Saturday, August 29, 2009 3:16 PM Subject: Re: [PHP] File Open Prompt? On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote: are u shure, u dont send anything out before u send the headers? even one space would be too much. ralph_def...@yahoo.de Dan Shirah mrsqua...@gmail.com wrote in message news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com... You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box. Try putting all of that inside of a headers_sent(){} block. If nothing is displayed, it means that you've already sent something to the browser, so the headers have already been sent and the extra ones you are sending do nothing. This sort of thing is shown in your error log also. If you still get the tif displayed as text, then are you sure that the tif is valid? You may also try put these line at top of page to avoid anythings sent before your attachment headers error_reporting(E_ALL); ini_set('display_errors', 1); Which browsers you used to test it and their versions ? - Eric Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Open Prompt?
- Original Message - From: Eric blueray2...@yahoo.com To: a...@ashleysheridan.co.uk; Ralph Deffke ralph_def...@yahoo.de Cc: php-general@lists.php.net Sent: Saturday, August 29, 2009 5:01 PM Subject: Re: [PHP] File Open Prompt? - Original Message - From: Ashley Sheridan a...@ashleysheridan.co.uk To: Ralph Deffke ralph_def...@yahoo.de Cc: php-general@lists.php.net Sent: Saturday, August 29, 2009 3:16 PM Subject: Re: [PHP] File Open Prompt? On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote: are u shure, u dont send anything out before u send the headers? even one space would be too much. ralph_def...@yahoo.de Dan Shirah mrsqua...@gmail.com wrote in message news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com... You will need to add some headers to the page to popup the prompt, at least with these. $filename = 'somefile.tif'; $filesize = filesize($filename); header('Content-Type: application/force-download'); header('Content-disposition: attachement; filename=' . $filename); header('Content-length: ' . $filesize); Eric I don't know what I'm doing wrong. I've tried: header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Length: ' . filesize($filename)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); AND if (file_exists($new_file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($new_file )); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($new_file)); ob_clean(); flush(); readfile($new_file); exit; } But everything I do just sends heiroglyphics to the screen instead of giving the download box. Try putting all of that inside of a headers_sent(){} block. If nothing is displayed, it means that you've already sent something to the browser, so the headers have already been sent and the extra ones you are sending do nothing. This sort of thing is shown in your error log also. If you still get the tif displayed as text, then are you sure that the tif is valid? You may also try put these line at top of page to avoid anythings sent before your attachment headers error_reporting(E_ALL); ini_set('display_errors', 1); Which browsers you used to test it and their versions ? Also, did you browse it directly or through a secondary page ? It should used on a second page. i.e. page1.php a href=download.php?id=10download/a download.php header( -Eric Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling extension function from another
On Sat, Aug 29, 2009 at 10:14 AM, leledumbo leledumbo_c...@yahoo.co.idwrote: extension A has function a, extension B has function b. How can I make b calls a? What is an extension? -- View this message in context: http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25200892.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling extension function from another
2009/8/28 leledumbo leledumbo_c...@yahoo.co.id: Is it possible to call a function that resides in an extension from another extension? It's certainly possible but I've never needed to do it so I don't know how. I suggest you ask this question on the PHP Internals list. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Best way to test for form submission?
At 5:33 PM +0100 8/28/09, Ashley Sheridan wrote: On Fri, 2009-08-28 at 12:28 -0400, tedd wrote: Ash: What catches me every once in a while is using variable names that are the same as $_SESSION indexes, such as: $session_name = $_SESSION['session_name']; Believe it or not, that does NOT always work! Sometimes I have to do this -- $my_session_name = $_SESSION['session_name']; -- to get around the problem. I have experienced this error more than once -- it's strange. Cheers, tedd Does that happen even with register globals off? Yes. it happens with register globals set to off Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Best way to test for form submission?
At 5:51 PM +0100 8/28/09, Ashley Sheridan wrote: I usually just tend to use the $_REQUEST array instead of $_POST or $_GET. You get the benefit of being able to work with both arrays (as well as $_SESSION and $_COOKIE) without any drawbacks. Thanks, Ash Ash: Drawbacks are funny things. Not knowing where my data originated ($_GET, $_POST, or $_COOKIE) and having the possibility of what I was expecting overridden in a $_REQUEST is what I would call a drawback. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Best way to test for form submission?
At 1:18 AM -0700 8/29/09, Warren Vail wrote: To test a form I usually send the form contents to a php file that contains the following; foreach($_POST as $nm = $val) echo _POST[.$nm.] [.$val.]br; foreach($_GET as $nm = $val) echo _GET[.$nm.] [.$val.]br; Checkboxes and radio buttons only send their value if the control is checked. That's correct, here's the way I solve both types: http://php1.net/b/form-radio http://php1.net/b/form-radio1 http://php1.net/b/form-checkbox/ http://php1.net/b/form-checkbox1/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Comparison
At 1:01 PM -0400 8/28/09, David Stoltz wrote: Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. Whoa dude! You just received advice from a brilliant man and you are bitching about it?!? Look child, you are being told what you should do by a professional who is donating his time freely to help you. Just how did you not understand that? So, just do what he advised and say Thank you sir, may I have another? I've posted some dumb-ass questions before, but only after I took the time to research the question myself. And when someone took the time to straighten me out and help, I appreciated it. Hopefully next time you'll read the manual and take the time to understand what you read -- it would cut down on post that demonstrate just how ignorant and thankless you are at this. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Best way to test for form submission?
Warren Vail wrote: To test a form I usually send the form contents to a php file that contains the following; foreach($_POST as $nm = $val) echo _POST[.$nm.] [.$val.]br; foreach($_GET as $nm = $val) echo _GET[.$nm.] [.$val.]br; Checkboxes and radio buttons only send their value if the control is checked. You can have multiple submit buttons (type=submit) on a form, but you should assign them different name parameters to recognize which one is clicked (any one of them will cause the form to be submitted, but the only one that will establish a $_POST entry named submit is the submit control that is named submit (name=submit). I would suggest NOT naming any field submit. There will come a time when you will want to do form.submit() in JavaScript and you will find it broken in one of the browsers. I'm not sure which, but one of them breaks if you have named a field submit. As a result I always use continue instead :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Best way to test for form submission?
On 8/29/09 9:29 AM, tedd tedd.sperl...@gmail.com wrote: At 1:18 AM -0700 8/29/09, Warren Vail wrote: To test a form I usually send the form contents to a php file that contains the following; foreach($_POST as $nm = $val) echo _POST[.$nm.] [.$val.]br; foreach($_GET as $nm = $val) echo _GET[.$nm.] [.$val.]br; Checkboxes and radio buttons only send their value if the control is checked. That's correct, here's the way I solve both types: http://php1.net/b/form-radio http://php1.net/b/form-radio1 http://php1.net/b/form-checkbox/ http://php1.net/b/form-checkbox1/ warren's test script above doesn't work so well with tedd's scheme for naming radios checkboxs. tedd uses name=option[] in the markup so in warren's script, when $nm is 'option', $val will be an array so it won't convert to a string in .$val.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Login should not allow users to login if the application is logged in with the same login credentials
Balasubramanyam A knowledge.wea...@gmail.com wrote in message news:893c34ce0908270424n2d81596dq8529f13818dc9...@mail.gmail.com... Hello, I've written a simple application, where users need to login to access the features of the application. I want to develop login system such that, if user is already logged in, the application should not allow the users to login with the same login credentials. How do I accomplish this? Regards, Balu Personally, I have a table for sessions - each time a user logs in, their session is stored in the table, along with the session_id generated by session_start(), the userID, the time the session was last active, and an active flag. I use these fields to keep track of the users activity. If at any point the active flag is changed to inactive, the user's session is destroyed, and they are required to log in again. What you would do in your case, to only allow the user to be logged in at one location at any given time would be to automatically change the flag to 'inactive' on all the sessions in the table, associated with that users ID. Thus, if there is an active session elsewhere, when a new session is started, all other sessions associated with that ID will be kicked out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] starting session with AJAX
Ok, so I've got an authentication/login form that is powered by ajax. The user logs in, is authenticated, and the last step is to start a session and save the necessary information in the $_SESSION vars. For some reason, it appears (and almost of makes sense) that the session that is started via the AJAX is lost once the ajax is complete. AJAX calls the php, passing username and password Php executes all the necessary authentication, etc etc If, login is valid, it calls mySessionStart() (see below) Checks to make sure the session has been started using isLoggedIn() (below), which returns true AJAX closes, receiving a successfully logged in message. AJAX turns around and makes a second call, calling isLoggedIn() again, and the session is gone What I'm *guessing* is that because the PHP is not running on the active page, but in the background the session is not being set for the active page. Is there a way to pass the session back to the browser? - John Debugging code has been removed for readability: ** function mySessionStart($persist, $sessionID, $sessionKey, $debug=0){ session_start(); $_SESSION['sessDBID'] = $ sessionID; $_SESSION['sessKey'] = $ sessionKey; $_SESSION['persist'] = $persist; // if persist, set cookie if ($persist){ return myCreateCookie($persist, $ sessionID, $ sessionKey, $debug); }else{ return true; } } function isLoggedIn($debug = 0){ global $COOKIE_NAME; // if there is an active session. if (isset($_SESSION) $_SESSION['sessDBID'] != '' $_SESSION['sessKey'] != ){ //. check the contents return authenticate($_SESSION['sessDBID'], $_SESSION['sessKey']); // or, check for (persistent) cookie. }elseif (isset($_COOKIE[$COOKIE_NAME]) $_COOKIE[$COOKIE_NAME] != ){ $sessInfo = split('-', $_COOKIE[$COOKIE_NAME]); // . and check the contents if(authenticate($sessInfo[1], $sessInfo[0], $debug)){ // reset the cookie mySessionStart(true, $sessInfo[1], $sessInfo[0], $debug); }else{ // cookie authentication failed return false; } }else{ // there is no session or cookie return false; } }
RE: [PHP] user permissions
In this mechanism, does a role differ significantly from a group? I have to admin a CRM system that has both roles /and/ groups, and it always seems a bit excessive. But maybe there's some benefit to roles, as such, that I'm not seeing. Thanks, Ben [JP] As described, a role appears to act essentially the same as a group - a predefined set of permissions that can be assigned to multiple users (as opposed to a set of permissions unique to the user). Correct me if there's a better way, but I think individual permissions can be set similarly - except skip the role/group step and associate the binary permission string directly with the user. Thinking outloud: In your case where you're dealing with both individual permissions as well as groups, you could do both of the above, but have the individual permissions override the group. You'd have to figure out a third bit though, to act as a no change bit. Ie: 0 = deny, 1 = allow, 2 = NC. But, that wouldn't allow you to convert and store the bit string in decimal. So if group1 had a permission string of 1010, and user Joe was a member of group1, but you wanted to take away the first bit's permission, and grant the second bit, you could assign him the individual permission string of 0122 (deny, allow, NC, NC), resulting in his permissions being 0110. You'd check it by checking the individual permissions first, and if the bit (or digit in this case) were 2, then you would move on to checking the group permissions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] user permissions
As described, a role appears to act essentially the same as a group - a predefined set of permissions that can be assigned to multiple users (as opposed to a set of permissions unique to the user). [JP] I should say, the logic of a role is essentially the same as the logic behind a group. It just adds, as Phpster said, another layer of control -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: starting session with AJAX
I found two small errors in the isLoggedIn(), which are corrected below. They don't have any effect on the issue at hand though. ** function isLoggedIn($debug = 0){ global $COOKIE_NAME; // if there is an active session. if (isset($_SESSION) $_SESSION['sessDBID'] != '' $_SESSION['sessKey'] != ){ //. check the contents return authenticate($_SESSION['sessDBID'], $_SESSION['sessKey']); // or, check for (persistent) cookie. }elseif (isset($_COOKIE[$COOKIE_NAME]) $_COOKIE[$COOKIE_NAME] != ){ $sessInfo = split('-', $_COOKIE[$COOKIE_NAME]); // . and check the contents if(authenticate($sessInfo[0], $sessInfo[1], $debug)){ // reset the cookie return (mySessionStart(true, $sessInfo[0], $sessInfo[1], $debug)); }else{ // cookie authentication failed return false; } }else{ // there is no session or cookie return false; } }
[PHP] RE: starting session with AJAX
Nevermind. It was a simple mistake - I had session_start() on the page the ajax was calling from, but not at the beginning of the php script it was calling to.
[PHP] Re: PHP Crash in file_get_contents
on a regulary base I read the docs even on functions I know, I just read about the funstion u use and the doc says this: Note: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode(). did u try to avoid the problem by using urlencode ? just a thought ralph_def...@yahoo.de Seth Hill set...@gmail.com wrote in message news:a90c87ed0908271150x18202147n1717d24daf141...@mail.gmail.com... Hello all, I'm experiencing a curious error that I'm hoping someone can help with. I am using file_get_contents() with Google Maps Geocoding to retrieve information about an address. The URL that I'm requesting looks like: http://maps.google.com/maps/geo?q=[Search Subject]key=[google maps key]sensor=falseoutput=jsonoe=utf8 If I pass a space (0x20) in the search subject, I get a 400 error back (as it should be). However, the next request to the site crashes PHP. I can reproduce it as part of my whole site (which runs a custom framework), but I've been unable to come up with a single PHP file that will duplicate the problem. I am running PHP under IIS6 on a Windows 2003 Web Edition server. I have seen this with PHP 5.1.1 and PHP 5.2.5 using the ISAPI dll. Thinking that it was a known bug, I upgraded, but I still see it on PHP 5.2.10 with FastCGI. With ISAPI I get a PHP Access Violation message until I recycle the app pool, with FastCGI I get an equivalent message (except with FastCGI I don't have to manually restart anything). This is the stack trace: Function Arg 1 Arg 2 Arg 3 Source php5!_zend_mm_realloc_int+357 00223ea0 0274ab98 0008 php5!_erealloc+2e 0274ab98 0008 php5!php_stream_wrapper_log_error+49 1044b458 0004 10333244 php5!php_stream_url_wrap_http_ex+1f17 1044b458 027a2bb8 102a3780php5!php_stream_url_wrap_http+27 1044b458 027a2bb8 102a3780php5!_php_stream_open_wrapper_ex+aa 027a2bb8 102a3780 php5!zif_file_get_contents+e2 0001 0274a9e8 php5!zend_do_fcall_common_helper_SPEC+6d7 00c0a45c 00c0a2e8 000cphp5!ZEND_DO_FCALL_SPEC_CONST_HANDLER+df 00c0a45c 027492a4 0274912cphp5!execute+12e 02749af8 00c0a518 0028php5!zend_do_fcall_common_helper_SPEC+796 00c0aa64 10018e9e 00c0aa64 php5!ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER+10 00c0aa64 027a2cbc 0274a9bcphp5!execute+12e 0178e668 00c0ab40 0030 php5!ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER+332 0178e668 0178e3b4 0178e53cphp5!execute+12e 0178b368 00c0cba8 php5!ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER+2d1 0178b368 00c0cbac php5!execute+12e 0178b100 00c0fee0 php5!zend_execute_scripts+c8 0008 0003 php5!php_execute_script+1c0 00c0fee0 php_cgi!main+b2f 0001 00223c90 00222928 php_cgi!mainCRTStartup+e3 7ffd8000 kernel32!BaseProcessStart+23 00405cd6 I guess I'm asking for some pointers on how to narrow this down a bit, or if anyone has seen this problem before. I didn't find anything on the PHP bugs list. Regards, Seth Hill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
On Fri, 28 Aug 2009 17:22:20 -0600, LinuxManMikeC wrote: a href=?php echo $url; ?click here/a *Groan* Throw any random web site to an HTML validator and you're likely to see this kind of slop all over. The correct solution is of course: $u = htmlspecialchars ($url); echo a href=\$u\$u/a; [A more elaborate way to flay this feline is included below.] /Nisse /* Reworked from slightly different code. Bugs may have been introduced. */ ?php function url_to_links ($url) { if (preg_match ('@^([a-z]+://)(.*)@i', $url, $m)) { $prfx = $m[1]; $path = $m[2]; } else { return htmlspecialchars ($url); } $url_sofar = $prfx; $links = htmlspecialchars ($prfx); $segs = explode ('?', $path, 2); if (isset ($segs[1])) $query = $segs[1]; $segs = explode ('/', $segs[0]); for ($segn = 0; $segn count ($segs); $segn++) { $url_sofar .= $segs[$segn]; if (isset ($segs[$segn+1])) $url_sofar .= '/'; if ($segs[$segn] !== '') { $links .= 'a href=' . htmlspecialchars ($url_sofar) . '' . htmlspecialchars ($segs[$segn]) . '/a'; } if (isset ($segs[$segn+1])) $links .= '/'; } if (isset ($query)) { $url_sofar .= ?$query; $links .= '?a href=' . htmlspecialchars ($url_sofar) . '' . htmlspecialchars ($query) . '/a'; } return $links; } $u = 'https://ebagwa.example/abd/def/ghi?s=tu=vw=xy=z'; $u_h = htmlspecialchars ($u); $links = url_to_links ($u); header ('Content-Type: text/html'); echo _ !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; titleurl_to_links()/title pre $u_h #x2193; $links /pre _; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What is the best way to process live data?
For those of you that remember (not likely but anyway) I am working on some code that splits CLF records and feeds them into a database. What I need to do now is automate it. So what I have is a program (urlsnarf) that redirects its output (simple cmd file.txt) to a file. The script currently processes this output line by line and does the SQL foo - i.e. script.php /the/file.txt Should I: 1) do away with redirecting the output from urlsnarf to a file and have the script run the process and have some kind of handle on it; foreach kinda thing? 2) keep outputting the info to a persistent file, reading any new appends and periodically cull this file. Seems like a waste of I/O if #1 is possible. 3) other options? Any help/push in the right direction is appreciated. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
2009/8/29 Nisse Engström news.nospam.0ixbt...@luden.se: On Fri, 28 Aug 2009 17:22:20 -0600, LinuxManMikeC wrote: a href=?php echo $url; ?click here/a *Groan* Throw any random web site to an HTML validator and you're likely to see this kind of slop all over. The correct solution is of course: $u = htmlspecialchars ($url); echo a href=\$u\$u/a; Right... you do realize that you validate the HTML output of the executed PHP script, not the PHP script itself. All you really did was just show another way to skin the same cat. Get over yourself. As for your more elaborate example, I'm sure that heredoc will validate nicely. It also wouldn't hurt to read a book on algorithms and rethink your code so you aren't processing the same data over and over again. I see this kind of slop all over. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is the best way to process live data?
On Sat, Aug 29, 2009 at 3:31 PM, Paul Hallidaypaul.halli...@gmail.com wrote: For those of you that remember (not likely but anyway) I am working on some code that splits CLF records and feeds them into a database. What I need to do now is automate it. So what I have is a program (urlsnarf) that redirects its output (simple cmd file.txt) to a file. The script currently processes this output line by line and does the SQL foo - i.e. script.php /the/file.txt Should I: 1) do away with redirecting the output from urlsnarf to a file and have the script run the process and have some kind of handle on it; foreach kinda thing? 2) keep outputting the info to a persistent file, reading any new appends and periodically cull this file. Seems like a waste of I/O if #1 is possible. 3) other options? Any help/push in the right direction is appreciated. Thanks. I'd do away with the text file and snarf to my DB to begin with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
On Sat, 29 Aug 2009 16:19:05 -0600, LinuxManMikeC wrote: As for your more elaborate example, I'm sure that heredoc will validate nicely. It does. and rethink your code so you aren't processing the same data over and over again. I see this kind of slop all over. Touché! Would you believe that's on my todo list? Thanks for the reminder. :-) /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
2009/8/29 Nisse Engström news.nospam.0ixbt...@luden.se: On Sat, 29 Aug 2009 16:19:05 -0600, LinuxManMikeC wrote: As for your more elaborate example, I'm sure that heredoc will validate nicely. It does. Perhaps you haven't met a few good friends of mine. Their names are html, head, and body. So what crawled up your backside while you were reading my example? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting URL's to hyperlinks.
On Sat, 29 Aug 2009 16:47:47 -0600, LinuxManMikeC wrote: 2009/8/29 Nisse Engström news.nospam.0ixbt...@luden.se: On Sat, 29 Aug 2009 16:19:05 -0600, LinuxManMikeC wrote: As for your more elaborate example, I'm sure that heredoc will validate nicely. It does. Perhaps you haven't met a few good friends of mine. Their names are html, head, and body. The html, head and body elements are all there. They are mandatory. The tags however, are optional. /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OpenCart
I am wondering if anyone here can provide some hands-on feedback about this OS cart such as can it handle large catalogues of products and high amount of traffic? If you don't know about this cart or know of a better cart that is more closely suited to fulfill an enterprise level ecommerce need. Thank you, Marc Hall HallMarc Websites 610.446.3346 __ Information from ESET Smart Security, version of virus signature database 4380 (20090829) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php