Notice: Undefined index: op

Notice: Undefined index: op

am 22.02.2005 17:19:10 von Web

I get the error message:

*Notice*: Undefined index: op

When trying to set up a form. I have looked everywhere for the solution.
I don't understnadn how to define that index. The come it comes from is:

if ($_POST['op'] != 'ds') {
$display_block = "


Your E-mail Address:

subscribe

unsubscribe


";
}

I am trying to create a form which allows my users to join a mailing
list. I conceptually understand what the problem is but cannot find out
how to solve the problem. I cannot find out how to define 'op'. Please
do not tell me to lower my error reporting levels. I would rather fix
the problems. Thank you,
Joseph

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 17:47:43 von h.dudeness

> if ($_POST['op'] != 'ds') {
> $display_block = "
>


> Your E-mail Address:
>
> subscribe

> unsubscribe
>
>
>
";
> }


try:

if (isset($_POST['op']) && $_POST['op'] != 'ds')

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 17:49:35 von h.dudeness

On Tue, 22 Feb 2005 10:47:43 -0600, Matt M. wrote:
> > if ($_POST['op'] != 'ds') {
> > $display_block = "
> >


> > Your E-mail Address:
> >
> > subscribe

> > unsubscribe
> >
> >
> >
";
> > }
>
> try:
>
> if (isset($_POST['op']) && $_POST['op'] != 'ds')
>

sorry for 2 emails, looks like you would want
if (!isset($_POST['op']) || $_POST['op'] != 'ds')

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 17:51:42 von Gareth Heyes

Notices have been turned on your PHP installation. This means you will
need to declare all of your variables otherwise you will receive a
notice. To fix your problem simply declare your POST variable before
use.

if(isset($_POST['op'])) {
$op = $_POST['op'];
} else {
$op = "";
}

if($op != 'ds') {
etc.......

> I get the error message:
>
> *Notice*: Undefined index: op
>
> When trying to set up a form. I have looked everywhere for the
> solution. I don't understnadn how to define that index. The come it
> comes from is:
>
> if ($_POST['op'] != 'ds') {
> $display_block = "
>


> Your E-mail Address:
>
> > checked/>subscribe

> unsubscribe
>
>
>
";
> }
>
> I am trying to create a form which allows my users to join a mailing
> list. I conceptually understand what the problem is but cannot find
> out how to solve the problem. I cannot find out how to define 'op'.
> Please do not tell me to lower my error reporting levels. I would
> rather fix the problems. Thank you,
> Joseph
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 17:53:33 von Martin.Norland

J. Connolly wrote:
> I get the error message:
>
> *Notice*: Undefined index: op
>
> When trying to set up a form. I have looked everywhere for the solution.
> I don't understnadn how to define that index. The come it comes from is:
>
> if ($_POST['op'] != 'ds') {
> $display_block = "
>


> Your E-mail Address:
>
> subscribe

> unsubscribe
>
>
>
";
> }
>
> I am trying to create a form which allows my users to join a mailing
> list. I conceptually understand what the problem is but cannot find out
> how to solve the problem. I cannot find out how to define 'op'. Please
> do not tell me to lower my error reporting levels. I would rather fix
> the problems. Thank you,
> Joseph
$_POST is likely empty, because the user requesting the page has likely
not submitted the form (yet). What you probably want (since you aren't
going to lower the error reporting levels) is:

if ( isset($_POST['op']) && $_POST['op'] == 'ds' ) {
// do your operation here
} else {
// print your form/etc. here
}

You may want to use a different quoting style - I can't recall the name,
but it's taken from perl

echo <<

....
the rest of your stuff, then on its own line right at the beginning of
the line (no tabs/etc. :( )
....
EOF;

it basically echo's until it sees that delimiter, that could be EOD or
STOP or whatever (well, there might be reserved words issues - I could
more easily check if I could remember the name of the quoting style...)

Cheers
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 18:20:06 von Web

Thank you everyone for your help. None of the solutions helped though.
It is a long story, I have to use the undefined 'op' in a few places and
all f the solution end up causing other error. But I appreciate the help
and I understand when the problem is alot clearer.. I just turned off
the error reporting like everyone suggested. Maybe when I learn a bit
more I can go back and fix it. My application runs fine, I just like
everything to be 'perfect'.
jzf



Martin Norland wrote:

> J. Connolly wrote:
>
>> I get the error message:
>>
>> *Notice*: Undefined index: op
>>
>> When trying to set up a form. I have looked everywhere for the
>> solution. I don't understnadn how to define that index. The come it
>> comes from is:
>>
>> if ($_POST['op'] != 'ds') {
>> $display_block = "
>>
>> Your E-mail Address:
>>
>> >> checked/>subscribe

>> unsubscribe
>>
>>
>> ";
>> }
>>
>> I am trying to create a form which allows my users to join a mailing
>> list. I conceptually understand what the problem is but cannot find
>> out how to solve the problem. I cannot find out how to define 'op'.
>> Please do not tell me to lower my error reporting levels. I would
>> rather fix the problems. Thank you,
>> Joseph
>
> $_POST is likely empty, because the user requesting the page has
> likely not submitted the form (yet). What you probably want (since
> you aren't going to lower the error reporting levels) is:
>
> if ( isset($_POST['op']) && $_POST['op'] == 'ds' ) {
> // do your operation here
> } else {
> // print your form/etc. here
> }
>
> You may want to use a different quoting style - I can't recall the
> name, but it's taken from perl
>
> echo << >


> ...
> the rest of your stuff, then on its own line right at the beginning of
> the line (no tabs/etc. :( )
> ...
> EOF;
>
> it basically echo's until it sees that delimiter, that could be EOD or
> STOP or whatever (well, there might be reserved words issues - I could
> more easily check if I could remember the name of the quoting style...)
>
> Cheers

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 18:23:22 von Bret Hughes

On Tue, 2005-02-22 at 10:49, Matt M. wrote:
> On Tue, 22 Feb 2005 10:47:43 -0600, Matt M. wrote:
> > > if ($_POST['op'] != 'ds') {
> > > $display_block = "
> > >
> > > Your E-mail Address:
> > >
> > > subscribe

> > > unsubscribe
> > >
> > >
> > > ";
> > > }
> >
> > try:
> >
> > if (isset($_POST['op']) && $_POST['op'] != 'ds')
> >
>
> sorry for 2 emails, looks like you would want
> if (!isset($_POST['op']) || $_POST['op'] != 'ds')
>

I vote for the first one.

Bret

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 18:31:22 von Martin.Norland

Bret Hughes wrote:
> On Tue, 2005-02-22 at 10:49, Matt M. wrote:
>
>>On Tue, 22 Feb 2005 10:47:43 -0600, Matt M. wrote:
[snip]
>>>try:
>>>
>>>if (isset($_POST['op']) && $_POST['op'] != 'ds')
>>>
>>
>>sorry for 2 emails, looks like you would want
>>if (!isset($_POST['op']) || $_POST['op'] != 'ds')
>>
>
> I vote for the first one.
>
> Bret

Your vote is misplaced - the first one isn't what he wanted... with that
statement, his form will never be printed and it can never be set.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 19:24:24 von Bastien Koert

if you conisder passing the $_POST['op'] to a var called $op, then you could
define the var $op as an empty string

$op ="";


Bastien

>From: "J. Connolly"
>To: PHP list
>Subject: Re: [PHP-DB] Notice: Undefined index: op
>Date: Tue, 22 Feb 2005 12:20:06 -0500
>
>Thank you everyone for your help. None of the solutions helped though. It
>is a long story, I have to use the undefined 'op' in a few places and all f
>the solution end up causing other error. But I appreciate the help and I
>understand when the problem is alot clearer.. I just turned off the error
>reporting like everyone suggested. Maybe when I learn a bit more I can go
>back and fix it. My application runs fine, I just like everything to be
>'perfect'.
>jzf
>
>
>
>Martin Norland wrote:
>
>>J. Connolly wrote:
>>
>>>I get the error message:
>>>
>>>*Notice*: Undefined index: op
>>>
>>>When trying to set up a form. I have looked everywhere for the solution.
>>>I don't understnadn how to define that index. The come it comes from is:
>>>
>>>if ($_POST['op'] != 'ds') {
>>> $display_block = "
>>>


>>> Your E-mail Address:
>>>
>>> >>>checked/>subscribe

>>> unsubscribe
>>>
>>>
>>>
";
>>>}
>>>
>>>I am trying to create a form which allows my users to join a mailing
>>>list. I conceptually understand what the problem is but cannot find out
>>>how to solve the problem. I cannot find out how to define 'op'. Please do
>>>not tell me to lower my error reporting levels. I would rather fix the
>>>problems. Thank you,
>>>Joseph
>>
>>$_POST is likely empty, because the user requesting the page has likely
>>not submitted the form (yet). What you probably want (since you aren't
>>going to lower the error reporting levels) is:
>>
>>if ( isset($_POST['op']) && $_POST['op'] == 'ds' ) {
>> // do your operation here
>>} else {
>> // print your form/etc. here
>>}
>>
>>You may want to use a different quoting style - I can't recall the name,
>>but it's taken from perl
>>
>>echo << >>

>>...
>>the rest of your stuff, then on its own line right at the beginning of the
>>line (no tabs/etc. :( )
>>...
>>EOF;
>>
>>it basically echo's until it sees that delimiter, that could be EOD or
>>STOP or whatever (well, there might be reserved words issues - I could
>>more easily check if I could remember the name of the quoting style...)
>>
>>Cheers
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 21:01:36 von Bret Hughes

On Tue, 2005-02-22 at 11:31, Martin Norland wrote:
> Bret Hughes wrote:
> > On Tue, 2005-02-22 at 10:49, Matt M. wrote:
> >
> >>On Tue, 22 Feb 2005 10:47:43 -0600, Matt M. wrote:
> [snip]
> >>>try:
> >>>
> >>>if (isset($_POST['op']) && $_POST['op'] != 'ds')
> >>>
> >>
> >>sorry for 2 emails, looks like you would want
> >>if (!isset($_POST['op']) || $_POST['op'] != 'ds')
> >>
> >
> > I vote for the first one.
> >
> > Bret
>
> Your vote is misplaced - the first one isn't what he wanted... with that
> statement, his form will never be printed and it can never be set.
>

You are right of course, In looking at the original post I misread it
to be if (! $_POST['op'] != 'ds ). I guess Since this is the sort of
construct I have cleaned up the most lately. Actually most of what I
have been finding is stuff like if (!$varname ){
That is, doing something if a variable is not set to a true value and
also using that for a test for existence.

turn on notices and get a lesson on how to make a log file grow quickly
:)

Bret

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Notice: Undefined index: op

am 22.02.2005 22:57:47 von Jochem Maas

Martin Norland wrote:
> J. Connolly wrote:
>

....

> You may want to use a different quoting style - I can't recall the name,
> but it's taken from perl

HEREDOC. (i believe its custom to write it in capitals,)

>
> echo << >
> ...
> the rest of your stuff, then on its own line right at the beginning of
> the line (no tabs/etc. :( )
> ...
> EOF;
>
> it basically echo's until it sees that delimiter, that could be EOD or
> STOP or whatever (well, there might be reserved words issues - I could
> more easily check if I could remember the name of the quoting style...)
>
> Cheers

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php