Results 1 to 5 of 5

Thread: Undefined offset

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Undefined offset

    I am getting Undefined notice. Could anybody help out. Below are code
    -------------------------------
    <?PHP set_time_limit(0); require("./dbconfig/db_connect.php");
    //////////////////////////////////////SEARCH BARCODE TAG//////////////////////

    $lines = glob("D:/nusphere/apache/htdocs/Msafe/phonoApp/final/ftp_downloaded/*.txt");
    for($i=0;$i<sizeof($lines);$i++){ $fp=fopen($lines[$i],"r+") or die("error opening");
    $file_content =fread($fp,filesize($lines[$i]));
    fclose($fp);
    $arrContent=explode("\n",$file_content);
    //print_r($arrContent);
    //check to see if this is your search string
    SizeOf($arrContent);
    $barCodeinfo="";
    $trackOrder=0;
    $updateRecordCount=0; for($j=0;$j<sizeof($arrContent);$j++){ $arrData=explode(";",$arrContent[$j]);

    $barCode=$arrData[0];
    $SoundLink=$arrData[3];
    $Supplier_TrackID=$arrData[1];

    if($barCode<>$barCodeinfo){ $barCodeinfo=$barCode;
    $trackOrder=0; } else $trackOrder++;
    // echo "SELECT tbltracks.* FROM tbltracks,tblcollection WHERE tblcollection.barcode='".str_replace("'","''",trim($barCode))."' ORDER BY tbltracks.ID Limit ".($trackOrder).",1"."</br>"; // echo "UPDATE tbltracks SET Sound_Links='".($SoundLink)."' WHERE ID ='{$row['ID']}'"."</br>"; $rec = mysql_query("SELECT tbltracks.* FROM tbltracks,tblcollection WHERE tbltracks.FT_SuplProdID=tblcollection.suplprodid and tblcollection.barcode='".str_replace("'","''",trim($barCode))."' ORDER BY tbltracks.ID Limit ".($trackOrder).",1"); $updateRecordCount++; //OK if ($row = mysql_fetch_array($rec)){ mysql_query("UPDATE tbltracks SET Sound_Links='".($SoundLink)."' WHERE ID ='{$row['ID']}'"); echo "Updating ......................."; } else{}; } if($updateRecordCount%50) sleep(1); } ?>
    -------------------------------

    Thanks
    Ramesh chaudhary
    Last edited by RameshChaudhary; Nov 30th, 2006 at 06:02 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Undefined offset

    I'm not going to look through your jumbled mess of code. if you want help, you're going to need to sort all of that out for yourself, and post it so that it's READABLE.

    however, if the red highlighted line is the problem, then it's probably because your explode() isn't picking up $arrData[3], which means it doesn't have 4 items in it. you could suppress the error by defining the $arrData variables with @$arrData[3], or you could check if they exist before assigning them values. either way, that value will still be blank.

    you could also edit your PHP.ini to turn down the level of your error_reporting so that notices like that won't be displayed.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Undefined offset

    Quote Originally Posted by kows
    you could also edit your PHP.ini to turn down the level of your error_reporting so that notices like that won't be displayed.
    That's a disastarous idea. Errors and notices should be fixed, not hidden.

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Undefined offset

    I didn't say it was a good idea, I just said that he could.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Undefined offset

    But you didn't say it wasn't a good idea either, thus giving the impression that you endorse it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width