Re: Help please: undefined index in sample code
| From: | Herhuth, Ron | Date: | Mon, 16 Jun 2003 12:09:22 +0000 |
| Subject: | Re: Help please: undefined index in sample code | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-20344@lists.php.net to get a copy of this message | ||
Undefined index is an error generated due to something trying to access a
value in an array that doesn't exist. That array can be the form elements
array. You should check all values with the " !isset " function to see if
they exist before trying to access them in case the user did not enter a
value that you are expecting to be there.
Ron
>From: toby z
>To: Stephen
>Sent: 06/16/2003 5:43 AM
>my dear man
>if u try
>
>>> $tireqty = $_POST['tireqty'];
>
>with register globals on
>
>it gives u the same error :)
>
>i didn ask that without any reazon
>
>toby
>
>--- Stephen <stephen.edmonds5@btinternet.com> wrote: > Which just
>goes to show some people will say anything...
>>
>> I don't think this has anything to do with register globals (Sorry
>> toby).
>> Undefined index sounds like php is just warning you that you are
>> using a
>> variable without a value. Since you are using a form to send data,
>> this can
>> occur. To be honest, its a fairly pointless warning, so you
>> probably want to
>> ignore it. In your php.ini file search for and find the
>> error_reporting
>> option. I recommend you change your settings to
>> error_reporting = E_ALL & ~E_NOTICE
>> This should solve your problem.
>>
>> ----- Original Message -----
>> From: "Stuart Felenstein" <stuart4m@yahoo.com>
>> To: <php-windows@lists.php.net>
>> Sent: Saturday, June 14, 2003 10:18 AM
>> Subject: Re: [PHP-WIN] Help please: undefined index in sample code
>>
>>
>> > Yes, register globals are now on. Though it doesn't apparently
>> matter.
>> >
>> > Stuart
>> >
>> > toby z <blue_myth_1@yahoo.com> wrote:
>> > register globals on or off ?????
>> >
>> > --- Stuart Felenstein wrote: > I can't believe
>> > Chapter 1 , section 1 and I'm off to a bad start
>> > > already.
>> > > Using this form and script, I keep getting "undefined index"
>> for
>> > > the variables I declare in the script. Running PHP 4.3.2 on XP
>> > > Pro. Thanks.
>> > > Stuart
>> > >
>> > > Form:
>> > >
>> > >
>> > >
>> > >
>> > > Item
>> > > Quantity
>> > >
>> > >
>> > > Tires
>> > > [input] > maxlength="3">
>> > >
>> > >
>> > > Oil
>> > > [input] > maxlength="3">
>> > >
>> > >
>> > > Spark Plugs
>> > > [input] > maxlength="3">
>> > >
>> > >
>> > > [input] > Order">
>> > >
>> > >
>> > >
>> > >
>> > > Script:
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > Bob's Auto Parts
>> > > Order Results
>> > > > //create short variable names
>> > > $tireqty = $_POST['tireqty'];
>> > > $oilqty = $_POST['oilqty'];
>> > > $sparkqty = $_POST['sparkqty'];
>> > > ?>
>> > > > echo '
>> > Your order is as follows:
>> > ';
>> > > echo $tireqty.' tires
>> > ';
>> > > echo $oilqty.' bottles of oil
>> > ';
>> > > echo $sparkqty.' spark plugs
>> > ';
>> > > ?>
>> > >
>> > >
>> > >
>> >
>> >
>>
>________________________________________________________________________
>> > Want to chat instantly with your online friends? Get the FREE
>> Yahoo!
>> > Messenger http://uk.messenger.yahoo.com/
>>
>>
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>________________________________________________________________________
>Want to chat instantly with your online friends? Get the FREE Yahoo!
>Messenger http://uk.messenger.yahoo.com/
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
-- Ron Herhuth
-- Senior Developer
-- ron.herhuth@tatumpartners.com