Re: [PHP] Type of form element

2005-11-09 Thread Jake Gardner
Uh isset will work in this particular instance because $_POST is an array whose values are of one type and one type only: STRINGS. Yes, it is true that: $myArray['a'] = NULL; isSet($myArray['a']); //Will return FALSE. However, because $_POST contains STRINGS AND STRINGS ONLY, isSet works:

Re: [PHP] Type of form element

2005-11-08 Thread Richard Lynch
On Mon, October 31, 2005 2:53 pm, Marcus Bointon wrote: Take apart this operation: $a = isset($myarray['a']); Implicit in this simple line is a 'hidden' step which is to look up the index 'a' in $myarray to get its value before testing if it is No. I don't care what the value is, and

Re: [PHP] Type of form element

2005-11-08 Thread Richard Lynch
On Mon, October 31, 2005 4:56 pm, Marcus Bointon wrote: Yesterday I encountered an error in a large commercial php script and it turned out that it was looking in $_SERVER['SERVER_NAME'] which was there but set to NULL for some reason, and their test with isset was failing. So it's not just

Re: [PHP] Type of form element

2005-11-08 Thread Ben Ramsey
On 11/8/05 11:38 PM, Richard Lynch wrote: If you want to stuff NULL into something, and then use is_null() that makes sense. If you want to stuff NULL in there, and then use isset(), I'm not quite sure why you'd put NULL in there in the first place, but I don't rightly know what I'd expect

Re: [PHP] Type of form element

2005-11-08 Thread Ben Ramsey
On 11/8/05 11:52 PM, Ben Ramsey wrote: I know this is off-topic for this thread, but just as I see isset() misused (as in this case), I often see empty() misused. For example, when using empty(), the following all return TRUE: On second thought, misused is the wrong word. I mean

RE: [PHP] Type of form element

2005-11-02 Thread Ford, Mike
-Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: 31 October 2005 17:19 To: Marcus Bointon Marcus Bointon wrote: The thing I was wrong on is that PHP converts unset parameters (as opposed to nonexistent ones which it obviously can't do anything about) to

Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon
On 31 Oct 2005, at 06:18, Richard Lynch wrote: But I really do believe isset($_POST['checkbox_name']) is a good coding practice. OK, so PHP may not pass through unset params as NULL (it's not up to the browser), but if you don't select any checkboxes at all, the param won't exist, and

Re: [PHP] Type of form element

2005-10-31 Thread Chris Shiflett
Marcus Bointon wrote: OK, so PHP may not pass through unset params as NULL (it's not up to the browser) Well, it's certainly not up to PHP. Think about it. Let me give you an example to try: form action=test.php method=POST input type=checkbox name=foo value= / input type=submit / /form pre

Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon
On 31 Oct 2005, at 14:54, Chris Shiflett wrote: Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons: No, no, that's not what I said - I wouldn't contemplate such

Re: [PHP] Type of form element

2005-10-31 Thread Robert Cummings
On Mon, 2005-10-31 at 11:33, Marcus Bointon wrote: On 31 Oct 2005, at 14:54, Chris Shiflett wrote: Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons: No,

Re: [PHP] Type of form element

2005-10-31 Thread Chris Shiflett
Marcus Bointon wrote: The thing I was wrong on is that PHP converts unset parameters (as opposed to nonexistent ones which it obviously can't do anything about) to an empty string, e.g. given ?a=b=1, $_REQUEST ['a'] is , not NULL. That's right, except we seem to have a vocabulary discrepancy:

Re: [PHP] Type of form element

2005-10-31 Thread Richard Lynch
On Mon, October 31, 2005 4:38 am, Marcus Bointon wrote: On 31 Oct 2005, at 06:18, Richard Lynch wrote: But I really do believe isset($_POST['checkbox_name']) is a good coding practice. OK, so PHP may not pass through unset params as NULL (it's not up to the browser), but if you don't select

Re: [PHP] Type of form element

2005-10-31 Thread Richard Lynch
On Mon, October 31, 2005 10:33 am, Marcus Bointon wrote: On 31 Oct 2005, at 14:54, Chris Shiflett wrote: Hopefully it is also clear that your argument revolves around the idea that PHP would create $_POST['foo'] as NULL if the checkbox is not checked. This is wrong for two reasons: No, no,

Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon
On 31 Oct 2005, at 17:55, Richard Lynch wrote: You're wrong. No. You're just missing what I'm on about. I'll agree it's very dull. isset() does not, under any circumstances, create an index nor a variable. Quite right; I never said it did. Its entire purpose *IS* to tell you if something

Re: [PHP] Type of form element

2005-10-31 Thread Chris Shiflett
Marcus Bointon wrote: But that's not the question you're using isset to answer. You just want to know if something exists - you probably don't even care what its value is. I think this is where some (most?) of the misunderstanding originates. Testing to see whether something exists is exactly

Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon
On 31 Oct 2005, at 21:11, Chris Shiflett wrote: I think this is where some (most?) of the misunderstanding originates. Testing to see whether something exists is exactly what isset() does. No. Given $myarray['a'] = NULL, isset($myarray[a']) returns false. You're saying that therefore,

Re: [PHP] Type of form element

2005-10-31 Thread Chris Shiflett
Marcus Bointon wrote: Given $myarray['a'] = NULL, isset($myarray[a']) returns false. Yes, I think we've established that. I'm sure Richard and I were both well aware of this fact, but just in case we weren't, I think we can safely assume we are by now. :-) You're saying that therefore,

Re: [PHP] Type of form element

2005-10-30 Thread Marcus Bointon
On 29 Oct 2005, at 20:59, Richard Lynch wrote: So you will most likely be using isset($_POST['checkbox_name']) rather than testing for on I classify using isset for checking for the existence of array keys to be a bad habit as in some common cases it will not work as you expect, for

Re: [PHP] Type of form element

2005-10-30 Thread Richard Lynch
On Sun, October 30, 2005 5:52 am, Marcus Bointon wrote: On 29 Oct 2005, at 20:59, Richard Lynch wrote: So you will most likely be using isset($_POST['checkbox_name']) rather than testing for on I classify using isset for checking for the existence of array keys to be a bad habit as in some

Re: [PHP] Type of form element

2005-10-29 Thread Richard Lynch
On Fri, October 28, 2005 10:00 am, Shaun wrote: I have some checkboxes on my page which correspond with boolean fields in my database - actually they are TINYINT's in which I store a 0 or 1 in for false and true values respectively. Is it possible to loop through all $_POST values to see if

[PHP] Type of form element

2005-10-28 Thread Shaun
Hi, I have some checkboxes on my page which correspond with boolean fields in my database - actually they are TINYINT's in which I store a 0 or 1 in for false and true values respectively. Is it possible to loop through all $_POST values to see if it is a checkbox? If so then for that element

Re: [PHP] Type of form element

2005-10-28 Thread Leif Gregory
Hello Shaun, Friday, October 28, 2005, 9:00:05 AM, you wrote: Is it possible to loop through all $_POST values to see if it is a checkbox? If so then for that element if it is equal to 'on' then change it to 1 otherwise change it to 0? Yes and no. 1. You can't determine by the POST variable

RE: [PHP] Type of form element

2005-10-28 Thread Jim Moseby
Is it possible to loop through all $_POST values to see if it is a checkbox? If so then for that element if it is equal to 'on' then change it to 1 otherwise change it to 0? foreach($_POST as $key = $value){ if

RE: [PHP] Type of form element

2005-10-28 Thread Jay Blanchard
[snip] I have some checkboxes on my page which correspond with boolean fields in my database - actually they are TINYINT's in which I store a 0 or 1 in for false and true values respectively. Is it possible to loop through all $_POST values to see if it is a checkbox? If so then for that