Re: [PHP] undefined offset

2012-04-26 Thread Jim Giner

Thanks.  That was it  -my last line was null.
- Original Message - 
From: "Stuart Dallas" 

To: "Jim Giner" 
Cc: 
Sent: Thursday, April 26, 2012 4:21 PM
Subject: Re: [PHP] undefined offset


On 26 Apr 2012, at 21:20, Jim Giner wrote:


Sorry - can't seem to find anything that explains this on google.

I'm using a List command to break out an array into distinct field names. 
I

keep getting these errors as I go thru my loop::

Notice: Undefined offset: 10 in (.) on line 151
Notice: Undefined offset: 9 in (.) on line 151
Notice: Undefined offset: 8 in (.) on line 151
Notice: Undefined offset: 7 in (.) on line 151
Notice: Undefined offset: 6 in (.) on line 151
Notice: Undefined offset: 5 in (.) on line 151
Notice: Undefined offset: 4 in (.) on line 151
Notice: Undefined offset: 3 in (.) on line 151
Notice: Undefined offset: 2 in (.) on line 151
Notice: Undefined offset: 1 in (.) on line 151

The array is loaded with
 while ($line = fgetcsv($hdlin))

My trouble line of code is:
  list($LastName, $FirstName,$MI, $Eventcode,$Event_Partner_Ln,
$Event_Partner_Fn, $Event_Partner_MI,$t,$u,$v,$Draw_pos) = $line;

I've confirmed that I have a field name for each element in my rows.  All
the rows are the same size naturally.  So - what is it telling me?


For every iteration of the loop or just once? If it's just once then you're 
not handling the possibility of a blank line. If more than once then the 
file doesn't contain what you think it contains.


-Stuart

--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/




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



Re: [PHP] undefined offset

2012-04-26 Thread Stuart Dallas
On 26 Apr 2012, at 21:20, Jim Giner wrote:

> Sorry - can't seem to find anything that explains this on google.
> 
> I'm using a List command to break out an array into distinct field names.  I 
> keep getting these errors as I go thru my loop::
> 
> Notice: Undefined offset: 10 in (.) on line 151
> Notice: Undefined offset: 9 in (.) on line 151
> Notice: Undefined offset: 8 in (.) on line 151
> Notice: Undefined offset: 7 in (.) on line 151
> Notice: Undefined offset: 6 in (.) on line 151
> Notice: Undefined offset: 5 in (.) on line 151
> Notice: Undefined offset: 4 in (.) on line 151
> Notice: Undefined offset: 3 in (.) on line 151
> Notice: Undefined offset: 2 in (.) on line 151
> Notice: Undefined offset: 1 in (.) on line 151
> 
> The array is loaded with
>  while ($line = fgetcsv($hdlin))
> 
> My trouble line of code is:
>   list($LastName, $FirstName,$MI, $Eventcode,$Event_Partner_Ln, 
> $Event_Partner_Fn, $Event_Partner_MI,$t,$u,$v,$Draw_pos) = $line;
> 
> I've confirmed that I have a field name for each element in my rows.  All 
> the rows are the same size naturally.  So - what is it telling me? 

For every iteration of the loop or just once? If it's just once then you're not 
handling the possibility of a blank line. If more than once then the file 
doesn't contain what you think it contains.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread kranthi
may be you can use a couple of var_dumps to see what's happening
behind the screens.


and... use a debugger like xdebug.. it'll be of help

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



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Ralph Deffke
by having a quick look on it, u have to work on a session base? otherwise it
could be done by the post data only. I'm trying to avoid to work on the
session, because it makes live a bit easier. if u can try.

I'm telling this, because as u metioned to unset the session stuff is wierd
and I wouldn't trust the session vars any more anyway.

ralph_def...@yahoo.de


""Miller, Terion""  wrote in message
news:c6b04cb6.49e1%kmille...@springfi.gannett.com...
Formatted as PHP
http://pastebin.ca/1534058


and a note before I get chewed about the weird setting and unsetting at the
top with the sessions...because believe I see it...but if you take the
unset() out..nothing works, I can't figure that out and maybe that is a
blatent thing I'm missing (prob) but I know that checking if a sesion is set
then immediately unsetting it is not logical, and I tried putting it like if
isset else unset but same results, nothing work all variables error'd  out
as undefined.



On 8/18/09 11:49 AM, "Miller, Terion"  wrote:

Hi Folks, after days of trying lots of different things, I'm must grovel to
the list and post my problem...which is I am unable to get my pagination to
work, it seems to not carry the session to the next page and I get the
"undefined offset error"

The page code is posted here since my email client seems to mess up the code
formatting: http://pastebin.ca/1534024

Thanks to any and all who have a look.
Terion


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





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



Re: [PHP] Undefined Offset Error with Pagination and Sessions

2009-08-18 Thread Miller, Terion
Formatted as PHP
http://pastebin.ca/1534058


and a note before I get chewed about the weird setting and unsetting at the top 
with the sessions...because believe I see it...but if you take the unset() 
out..nothing works, I can't figure that out and maybe that is a blatent thing 
I'm missing (prob) but I know that checking if a sesion is set then immediately 
unsetting it is not logical, and I tried putting it like if isset else unset 
but same results, nothing work all variables error'd  out as undefined.



On 8/18/09 11:49 AM, "Miller, Terion"  wrote:

Hi Folks, after days of trying lots of different things, I'm must grovel to
the list and post my problem...which is I am unable to get my pagination to
work, it seems to not carry the session to the next page and I get the
"undefined offset error"

The page code is posted here since my email client seems to mess up the code
formatting: http://pastebin.ca/1534024

Thanks to any and all who have a look.
Terion


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




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



Re: [PHP] Undefined offset

2004-03-01 Thread Jough P
I had read elsewhere on this list that it could be the case that  
$this->inputs[$i]  wasn't defined at $i.  That is why I encased the for 
loop in the if condition:
  if (sizeof($this->inputs) > 0)
  {
 for($i=0; $i <= sizeof($this->inputs); $i++)
 {
 .

I've used both the 'sizeof' functions and 'count'



On Mar 1, 2004, at 10:03 AM, Stuart wrote:

Jough P wrote:
Greetings all, I'm getting "Notice: Undefined offset" regarding this 
line of code while inside a for loop:
if($this->inputs[$i] == "user")
I assume the 'offset' that is undefined is $i.  But $i is defined is 
the for statement above it.
It doesn't mean that $i isn't defined. It means that $this->inputs[$i] 
isn't defined for the value of $i where the notice is generated.

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


Re: [PHP] Undefined offset

2004-03-01 Thread Richard Davey
Hello Jough,

Monday, March 1, 2004, 3:58:31 PM, you wrote:

JP> Greetings all, I'm getting "Notice: Undefined offset" regarding
this JP> line of code while inside a for loop: if($this->>inputs[$i]
== "user")

JP> I assume the 'offset' that is undefined is $i.  But $i is defined is
JP> the for statement above it.

$i should be in single-quotes, although it isn't the cause of the
error. Your var (inputs) isn't defined in your class.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] Undefined offset

2004-03-01 Thread Raditha Dissanayake
could be your $i > length of array

Jough P wrote:

Greetings all, I'm getting "Notice: Undefined offset" regarding this 
line of code while inside a for loop:
if($this->inputs[$i] == "user")

I assume the 'offset' that is undefined is $i.  But $i is defined is 
the for statement above it.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Undefined offset

2004-03-01 Thread Jough P
Oops, in my previous email I meant to say "Here's the WHOLE function".  
sorry about the typo, hope I didn't confuse...

On Mar 1, 2004, at 9:58 AM, Jough P wrote:

Greetings all, I'm getting "Notice: Undefined offset" regarding this 
line of code while inside a for loop:
if($this->inputs[$i] == "user")

I assume the 'offset' that is undefined is $i.  But $i is defined is 
the for statement above it.

Here's the while function:

   function draw()
   {
  echo "method\" 
ACTION=\"$this->action\">\n";
  if (count($this->inputs) > 0)
  {
 for($i=0; $i <= count($this->inputs); $i++)
 {
if($this->inputs[$i] == "user")
   NexForm::drawUserInputs();
if($this->inputs[$i] == "ctc")
   NexForm::drawCtcInputs();
 }
  }
  ?>
  echo "\n";
   }

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


Re: [PHP] Undefined offset

2004-03-01 Thread Stuart
Jough P wrote:
Greetings all, I'm getting "Notice: Undefined offset" regarding this 
line of code while inside a for loop:
if($this->inputs[$i] == "user")

I assume the 'offset' that is undefined is $i.  But $i is defined is the 
for statement above it.
It doesn't mean that $i isn't defined. It means that $this->inputs[$i] 
isn't defined for the value of $i where the notice is generated.

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


Re: [PHP] Undefined offset on Windows not on Apache?

2003-11-30 Thread Chris Williams
I don't believe the disputed line of script is being executed because just
before that line I include the following print statement,
echo "array size: " . count($zip_forward) . "  ID: $location_id";
which does not get executed when my conditional fails.

Right you are on the error reporting, I included error_reporting (E_ALL); in
my test script and can reproduce same error on Apache.

Chris


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Chris Williams wrote:
> > The first and last lines contain carriage returns. The second or middle
line
> > contains sample data.
> >
> > The script that reads and parses the data is:
> >
> >   $countLines = fopen("data.txt", "r");
> >   while (!feof($countLines))
> >   {
> >$newLine = fgets($countLines, 1024);
> >echo "line length:  " . strlen($newLine) . "";
> >if(strlen($newLine) > 0)
> >{
> >$newLine = ereg_replace ("\"", "", $newLine);
> >$zip_forward = explode(",",$newLine);
> >$location_id = trim($zip_forward[0]);
> >echo "array size: " . count($zip_forward) . "  ID: $location_id";
> >$zip_to = trim(substr($zip_forward[1], 0, 5));
> >}
> >   }
> >   fclose($countLines);
> >
> > What's odd here is that the last line, which has a length of 0, should
never
> > cause the if(strlen($newLine) > 0) to execute the lines of script
contained
> > within the if conditional. And in fact the lines DON'T get executed.
> > However, on the Windows server I get the following error
> > PHP Notice: Undefined offset: 1 in \debug.php on line 20. This points to
my
> > code that evaluates the second element of the array $zip_to =
> > trim(substr($zip_forward[1], 0, 5));
> >
> > If I never evaluate the $zip_forward[1] array element within the if
> > conditional, why would PHP test the array $zip_forward for the proper
number
> > of elements?
>
> Okay, if you're getting that NOTICE then the line of code is executing.
> So even though you think the strlen() line is failing, it's not.
>
> Anyhow, the whole issue here is just that your two servers have
> different error_reporting() levels. One is set to show NOTICES while the
> other is not. If you use @trim(...), you can suppress this warning.
>
> The code is running the same on both servers, though...
>
> --
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Re: [PHP] Undefined offset on Windows not on Apache?

2003-11-30 Thread John W. Holmes
Chris Williams wrote:
The first and last lines contain carriage returns. The second or middle line
contains sample data.
The script that reads and parses the data is:

  $countLines = fopen("data.txt", "r");
  while (!feof($countLines))
  {
   $newLine = fgets($countLines, 1024);
   echo "line length:  " . strlen($newLine) . "";
   if(strlen($newLine) > 0)
   {
   $newLine = ereg_replace ("\"", "", $newLine);
   $zip_forward = explode(",",$newLine);
   $location_id = trim($zip_forward[0]);
   echo "array size: " . count($zip_forward) . "  ID: $location_id";
   $zip_to = trim(substr($zip_forward[1], 0, 5));
   }
  }
  fclose($countLines);
What's odd here is that the last line, which has a length of 0, should never
cause the if(strlen($newLine) > 0) to execute the lines of script contained
within the if conditional. And in fact the lines DON'T get executed.
However, on the Windows server I get the following error
PHP Notice: Undefined offset: 1 in \debug.php on line 20. This points to my
code that evaluates the second element of the array $zip_to =
trim(substr($zip_forward[1], 0, 5));
If I never evaluate the $zip_forward[1] array element within the if
conditional, why would PHP test the array $zip_forward for the proper number
of elements?
Okay, if you're getting that NOTICE then the line of code is executing. 
So even though you think the strlen() line is failing, it's not.

Anyhow, the whole issue here is just that your two servers have 
different error_reporting() levels. One is set to show NOTICES while the 
other is not. If you use @trim(...), you can suppress this warning.

The code is running the same on both servers, though...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


RE: [PHP] Undefined offset notices

2003-02-20 Thread Ford, Mike [LSS]
> -Original Message-
> From: Shawn McKenzie [mailto:[EMAIL PROTECTED]]
> Sent: 20 February 2003 05:55
> 
> While debugging my code, that seems to work fine, I see 
> hundreds of these
> notices, many different ones with different offset numbers 
> same line number.
> 
> Notice: Undefined offset: 2 in
> D:\apps\www\test\themes\Family\includes\autotheme.inc.php on line 275
> 
> I would like to know what the notice pertains to (offset?)  
> Here's the code:
> 
> $commands is an associative array, $tmpparts and $tmpcmds are 
> integer index
> arrays.
> 
> $i = 0;  // Line 270
> while($i != count($tmpparts)) {
> $content = "?>".$tmpparts[$i];
> eval($content);
> foreach($command as $name => $cmds) {
> if($tmpcmds[$i] == $name) {

Here, the offset is $i -- it's telling you that there is no $i element in the array 
$tmpcmds.

> $docmd = $cmds;
> eval($docmd);
> }
> }
> $i++;
> } // Line 281

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP] Undefined offset notices

2003-02-19 Thread Ray Hunter
Try using a for loop instead of a while loop...

example:

for( $i = 0, $tot = count($tmpparts); $i < $tot; $i++ ) {
$content = "?>".$tmpparts[$i];
eval($content);
foreach($command as $name => $cmds) {
if($tmpcmds[$i] == $name) {
$docmd = $cmds;
eval($docmd);
}
}
}

NOT TESTED...check and see if it works..


--
Ray


On Wed, 2003-02-19 at 22:54, Shawn McKenzie wrote:
> While debugging my code, that seems to work fine, I see hundreds of these
> notices, many different ones with different offset numbers same line number.
> 
> (I know I can turn notices off)
> 
> Notice: Undefined offset: 2 in
> D:\apps\www\test\themes\Family\includes\autotheme.inc.php on line 275
> 
> I would like to know what the notice pertains to (offset?)  Here's the code:
> 
> $commands is an associative array, $tmpparts and $tmpcmds are integer index
> arrays.
> 
> $i = 0;  // Line 270
> while($i != count($tmpparts)) {
> $content = "?>".$tmpparts[$i];
> eval($content);
> foreach($command as $name => $cmds) {
> if($tmpcmds[$i] == $name) {
> $docmd = $cmds;
> eval($docmd);
> }
> }
> $i++;
> } // Line 281
> 
> TIA,
> Shawn
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




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




Re: [PHP] undefined offset && bad argument

2002-08-15 Thread Jason Wong

On Friday 16 August 2002 03:14, [EMAIL PROTECTED] wrote:
> I get this error:
>
> Notice: Undefined offset: 1 in
> /home/victor/argilent-www/sites/malibu_place_2/index.php on line 104

Which is line 104?


> Warning: Bad arguments to implode() in
> /home/victor/argilent-www/sites/malibu_place_2/index.php on line 106
> Error 5

Ditto.

Use print_r() to display your key variables at strategic points in your code 
to verify that they contain what you expect.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Actors will happen even in the best-regulated families.
*/


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




Re: [PHP] Undefined Offset Error

2002-07-02 Thread Jason Wong

On Tuesday 02 July 2002 20:35, Crane, Christopher wrote:
> Here is a piece of my code...
> Could someone tell me what I did wrong? I get the following errors;
>
> Warning: Undefined offset: 1 in c:/www/htdocs/demos/download/inx_news.php
> on line 33
> Warning: Undefined offset: 1 in c:/www/htdocs/demos/download/inx_news.php
> on line 34
>
> (obviously, the line numers will not be the same here)

Please indicate which is line 33.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
There's nothing wrong with teenagers that reasoning with them won't aggravate.
*/


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




[PHP] Re: [php] undefined offset?

2001-08-03 Thread Chris Lee



you never defined test[8] thats why its undeined. more likley then not check
in your php.ini file, i bet you have

  warning = ~E_WARNINGS E_ALL;
in your linux box and
  warning = E_ALL;
in your win box.

I like all warnings and errors showing, personal opinion.

--

  Chris Lee
  [EMAIL PROTECTED]



"Johnny Nguyen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Can somebody explain to me the undefined offset warning?
>
> Warning: Undefined offset: 8 in D:\filepath\CalendarClass.php on line 387
>
> It was working fine on linux, but when i moved to iis 5.0 running php i
got
> this error.
>
> Regards,
> Johnny Nguyen
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]