Re: Re: Has element of array been initialized?

From: Date: Tue, 08 Apr 2003 23:57:39 +0000
Subject: Re: Re: Has element of array been initialized?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-142979@lists.php.net to get a copy of this message
sorry, found problem. Using $seq as variable and array ;-(. ben At 00:31 09/04/2003 +0100, Ben Edwards wrote: >Guess I need to give a bit more context. > >The code below is used to update the database. It is run when a form with >multiple records is submitted. The array $product_code contains the codes >of the products and $seq the order they are to be displayed. > >for Example:- > >$product_code[1] = "ER", $seq[1] = 10 >$product_code[2] = "TY", $seq[1] = Unititialised > > >Problem is if the user blanks out the $seq field the element of the array >douse not seem to be set. > > if ( $action == "Save" ) { > > $count = count( $product_code ); > > for( $index=1; $index <= $count; ++$index ) { > > if ( isset( $seq[$index]) ) { > $seq = "'".$seq[$index]."'"; > } else { > $seq = "NULL"; > } > > echo( > "update products ". > "set seq=$seq ". > "where code='".$product_code[$index]."'" ); > } > > $action = "list"; > > } > >I get the followig error:- > >Notice: Uninitialized string offset: 3 in >d:\wwwroot\cultureshop\list_products.php on line 412 > > >At 17:19 08/04/2003 -0600, Rob Adams wrote: > > >>"Ben Edwards" <ben@videonetwork.org> wrote in message >>news:5.1.1.6.2.20030408235826.0344e170@mail.videonetwork.org... >> > I am trying to see if elements of a number indexed array are set, i.e. >> > something like:- >> > >> > if ( isset( $seq[$index]) ) { >> > echo $seq[$index]."<br>"; >> > } >> >>The only error I get when running this is when $index is undefined. I can >>call >>isset($seq[whatever number you please here]) >> without getting an error. >> >> > >> > Except in this case isset gives an error. How do i 'ask' if the element >> > has been initialized? >> > >> > Ben >> > >> > >> > **************************************************************** >> > * Ben Edwards Tel +44 (0)117 968 2602 ICQ 42000477 * >> > * Critical Site Builder >> > http://www.criticaldistribution.com * >> > * online collaborative web authoring content management system * >> > * Get alt news/views films online >> > http://www.cultureshop.org * >> > * i-Contact Progressive Video >> > http://www.videonetwork.org * >> > * Fun corporate graphics >> > http://www.subvertise.org * >> > * Bristol Indymedia ™‘Ý’@Ë«(A ®¢f >> > ahttp://bristol.indymedia.org * >> > * Bristol's radical news >> > http://www.bristle.org.uk * >> > **************************************************************** >> > >> >> >>---------------------------------------------------------------------------- >>---- >> >> >> > >> > --- >> > Outgoing mail is certified Virus Free. >> > Checked by AVG anti-virus system (http://www.grisoft.com). >> > Version: 6.0.465 / Virus Database: 263 - Release Date: 25/03/2003 >> > >> >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> >>--- >>Incoming mail is certified Virus Free. >>Checked by AVG anti-virus system (http://www.grisoft.com). >>Version: 6.0.465 / Virus Database: 263 - Release Date: 25/03/2003 > >**************************************************************** >* Ben Edwards Tel +44 (0)117 968 2602 ICQ 42000477 * >* Critical Site Builder http://www.criticaldistribution.com * >* online collaborative web authoring content management system * >* Get alt news/views films online http://www.cultureshop.org * >* i-Contact Progressive Video http://www.videonetwork.org * >* Fun corporate graphics http://www.subvertise.org * >* Bristol Indymedia http://bristol.indymedia.org * >* Bristol's radical news >http://www.bristle.org.uk * >**************************************************************** > > > >--- >Outgoing mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.465 / Virus Database: 263 - Release Date: 25/03/2003 > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > >--- >Incoming mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.465 / Virus Database: 263 - Release Date: 25/03/2003 **************************************************************** * Ben Edwards Tel +44 (0)117 968 2602 ICQ 42000477 * * Critical Site Builder http://www.criticaldistribution.com * * online collaborative web authoring content management system * * Get alt news/views films online http://www.cultureshop.org * * i-Contact Progressive Video http://www.videonetwork.org * * Fun corporate graphics http://www.subvertise.org * * Bristol Indymedia http://bristol.indymedia.org * * Bristol's radical news http://www.bristle.org.uk * ****************************************************************

« previous php.general (#142979) next »