Reply to Re: Undefined Index notices

Your name:

Reply:


Posted by Craig Morrison on 06/10/06 02:57

Bent Stigsen wrote:
> Craig Morrison wrote:
>
>> Bent Stigsen wrote:
>>> Craig Morrison wrote:
>>>> Bent Stigsen wrote:
>>>>> Craig Morrison wrote:
>>> [snip]
>>>>>> A form posts the value for D1 to a script, script looks for the value
>>>>>> of D1 and gets it. PHP raises a notice that D1 is undefined.
>>>>>>
>>>>>> I don't understand how I am getting the value that is posted to the
>>>>>> script if the index is undefined.
>>>>>>
>>>>>> Is it really that difficult for someone to explain this?
>>>>> Yes, because in all likelyhood, that is not what is happening.
>>>>>
>>>>> Arrays and forms are so commonly used that, if it was a bug then it
>>>>> would be reported all over the place.
>>>>>
>>>>>
>>>>> /Bent
>>>> I didn't say that it was a bug..
>>>>
>>>> I'd yell louder if I thought it was. :-)
>>> Sorry, if what you say is happening, really is happening, then it is a
>>> bug, and since you didn't take Markus seriously, I assumed you did think
>>> it was.
>> You shouldn't make assumptions, that is a fatal flaw. You assumed that I
>> didn't take his advice seriously. Don't jump to conclusions it makes you
>> look like a, well... That's another matter, read on..
>
> Yes yes, I know I can be an insensitive prick. Honestly, I try to better
> myself. Perhaps I grow up someday.
>
>>>> But I am getting the correct value, as you can see from the follow up
>>>> that I posted which does a print_r..
>>> You must be doing something or making assumptions that you consider
>>> unimportant to tell, because it doesn't make sense. Are you sure you are
>>> not seeing the notice *before* submitting the form, or subsequently do a
>>> redirect, or do some fiddling with the _POST-array elsewhere?
>> I am not making any assumptions, just writing code according to the
>> documentation. I gave the HTML that posts its results already..
>>
>> These are the first 3 lines of the script that gets posted to..
>>
>> <?
>> include 'inc/config.inc.php';
>> ?>
>>
>> The notice is generated in config.inc.php, which follows...
> [snip]
>> // determine what view we are querying
>> if ($_SERVER['REQUEST_METHOD'] == 'POST')
>> $id_option = $_POST['D1']; // <=== DING we have winner, notice gets raised
>> else if ($_SERVER['REQUEST_METHOD'] == 'GET')
>> $id_option = $_GET['D1'];
>>
>> if (($id_option == 0) || ($id_option > $id_text_count)) {$id_option = 1;}
>> $selectID = $id_view[$id_option];
>> ?>
>>
>> As you can see, there is nothing but good php there.
>
> Yes, it looks fine.
>
>> Now, here's where I get pissed off. You all assumed that I was just
>> pissing in the wind. I gave a good explanation of what I was doing
>> before and this code tells you nothing more.
>>
>> Next time, ask for answers before being an ass and assuming you are
>> working with a n00b..
>
> Sorry I couldn't be more sensitive in my wording, but I think you are being
> a bit touchy. For the record, I didn't think you were a n00b, just one of
> those guys with an infinite faith in their own infallibility, who
> apparently get all huffy at the mere suggestion that they made an error.

Touchy? I don't think so.

Is there any error in the code? If there is, by all means point it out.
That *is* the point behind posting it.

You seem to be on the track that I am trying to find fault here, which
is an error. I am not. So get over that.

I am simply trying to understand the behavior.

>
> If you find it to be some funky bug in PHP, then I will unreservedly
> apologize for anything you find fit. Alternatively when you find it to be
> some banal mistake in your code, I hope you'll find it in you to forgive my
> bruteness.

I still don't have an answer to the original query though.

As it stands, the app works and I may very well be being quite pedantic
about the whole mess but I would like some insight as to why the notice
is thrown. Which was the whole point behind this thread.

I showed the code that was throwing the notice and you (or anyone else)
have shed no light on the problem. I don't know what else I can do or
show to make it any clearer what is happening.

Maybe we both need to steer clear of the fan.

Craig

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация