Jump to content

Undefined Offset: 0


aebstract

Recommended Posts

[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 48
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 49
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 50
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 51
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 52
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 53
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 54
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 55
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 56
[sat Mar 06 12:03:07 2010] [error] [client 12.248.157.94] PHP Notice:  Undefined offset:  0 in /var/www/vhosts/outlawracing.com/httpdocs/insert.php on line 57

 

This is a continuation of the other post, though the memory issue has been taken care of. How does an undefined offset: 0 error come up? I need to get it fixed.

 

Here is my entire script I am running:

 

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include_once "connect.php";





$textData = file('array2.txt');

$dataArray = array();
$tempArray = array();
$array_start = false;

foreach ($textData as $line)
{
   if ($array_start && preg_match("/\[([^\]]*)\] => (.*)/", $line, $keyValue)!= 0)
   {
      $tempArray[$keyValue[1]] = $keyValue[2];
   }

   if(substr($line, 0, 1)=='(')
    {
      $array_start = true;
   }

   if(substr($line, 0, 1)==')')
    {
      $array_start = false;
      $dataArray[] = $tempArray;
      $tempArray   = array();
   }
}

$arraycount = count($dataArray);


for ($i = 0; $i <= $arraycount; $i++) {


$dataArray0 = $dataArray[$i][0];
$dataArray1 = $dataArray[$i][1];
$dataArray2 = $dataArray[$i][2];
$dataArray3 = $dataArray[$i][3];
$dataArray4 = $dataArray[$i][4];
$dataArray5 = $dataArray[$i][5];
$dataArray6 = $dataArray[$i][6];
$dataArray7 = mysql_real_escape_string($dataArray[$i][7]);
$dataArray8 = $dataArray[$i][8];
$dataArray9 = $dataArray[$i][9];
$dataArray10 = $dataArray[$i][10];
$dataArray11 = $dataArray[$i][11];
$dataArray12 = $dataArray[$i][12];
$dataArray13 = $dataArray[$i][13];
$dataArray14 = $dataArray[$i][14];
$dataArray15 = $dataArray[$i][15];


}


?>

 

The errors I got were sent to me from my web host, I get a solid white blank page.

Link to comment
Share on other sites

Try

error_reporting (E_ALL ^ E_NOTICE); 

 

But this is not a good idea.

 

You have an array that goes from $array[0] to $array[15] but you run through the loop too many times. For example, you know the array  has 15 elements, so you can have a for loop like this

 

for ($i=1; $i<=15; $i++)

 

As arrays are zero-indexed, you are getting this error. It must be fixed otherwise your script may not run properly.

Link to comment
Share on other sites

[sat Mar 06 12:53:51 2010] [error] [client 202.75.211.90] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[sat Mar 06 12:56:10 2010] [error] [client 211.155.228.169] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.