-1

I'm receiving the following errors when I run my PHP script. The script is supposed to do some mapping in the database via JOINs, and then export the results to a CSV file.

Notice: Undefined index: partterminologyname in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 358
Notice: Undefined index: YearID in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 359
Notice: Undefined index: MakeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 360
Notice: Undefined index: modelname in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 361
Notice: Undefined index: SubModelName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 362
Notice: Undefined index: EngineDesignationName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 363
Notice: Undefined index: EngineVINName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 364
Notice: Undefined index: Liter in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 365
Notice: Undefined index: CC in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 366
Notice: Undefined index: CID in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 367
Notice: Undefined index: Cylinders in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 368
Notice: Undefined index: BlockType in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 369
Notice: Undefined index: EngBoreIn in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 370
Notice: Undefined index: EngBoreInMetric in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 371
Notice: Undefined index: EngStrokeIn in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 372
Notice: Undefined index: EngStrokeMetric in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 373
Notice: Undefined index: FuelDeliveryTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 374
Notice: Undefined index: FuelDeliverySubTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 375
Notice: Undefined index: FuelSystemControlTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 376
Notice: Undefined index: FuelSystemDesignName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 377
Notice: Undefined index: AspirationName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 378
Notice: Undefined index: CylinderHeadTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 379
Notice: Undefined index: FuelTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 380
Notice: Undefined index: IgnitionSystemTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 381
Notice: Undefined index: EngineMfr.MfrName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 382
Notice: Undefined index: EngineVersion in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 383
Notice: Undefined index: ValvesPerEngine in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 384
Notice: Undefined index: BedLength in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 385
Notice: Undefined index: BedLengthMetric in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 386
Notice: Undefined index: BedTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 387
Notice: Undefined index: BodyNumDoors in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 388
Notice: Undefined index: BrakeSystemName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 389
Notice: Undefined index: BrakeABSName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 390
Notice: Undefined index: BrakeTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 391
Notice: Undefined index: BrakeFront.BrakeTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 392
Notice: Undefined index: BrakeRear.BrakeTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 393
Notice: Undefined index: DriveTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 394
Notice: Undefined index: MfrBodyCodeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 395
Notice: Undefined index: SpringTypeFront.SpringTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 396
Notice: Undefined index: SpringTypeRear.SpringTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 397
Notice: Undefined index: SteeringTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 398
Notice: Undefined index: TransmissionTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 399
Notice: Undefined index: TransmissionNumSpeeds in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 400
Notice: Undefined index: TransmissionControlTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 401
Notice: Undefined index: TransmissionMfrCode in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 402
Notice: Undefined index: TransmissionMfr.MfrName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 403
Notice: Undefined index: ElecControlled in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 404
Notice: Undefined index: WheelBase in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 405
Notice: Undefined index: WheelBaseMetric in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 406
Notice: Undefined index: VehicleTypeName in /home/icarcare/public_html/magmi/integration/scripts/fileimport.php on line 407

The code related to this is as follows...

// Write all the user records to the spreadsheet
/* fetch associative array */
while ($row = $results->fetch_assoc()) {

    fputcsv($handle, array(
        'admin',
        'base',
        'Default',
        'simple',
        '2',
        $brandprefix . $row['part_id'],
        $row['part_id'],
        '1',
        '1',
        'Enabled',
        'Description',
        'Short Description',
        $row['partterminologyname'],
        $row['YearID'],
        $row['MakeName'],
        $row['modelname'],
        $row['SubModelName'],
        $row['EngineDesignationName'],
        $row['EngineVINName'],
        $row['Liter'],
        $row['CC'],
        $row['CID'],
        $row['Cylinders'],
        $row['BlockType'],
        $row['EngBoreIn'],
        $row['EngBoreInMetric'],
        $row['EngStrokeIn'],
        $row['EngStrokeMetric'],
        $row['FuelDeliveryTypeName'],
        $row['FuelDeliverySubTypeName'],
        $row['FuelSystemControlTypeName'],
        $row['FuelSystemDesignName'],
        $row['AspirationName'],
        $row['CylinderHeadTypeName'],
        $row['FuelTypeName'],
        $row['IgnitionSystemTypeName'],
        $row['EngineMfr.MfrName'],
        $row['EngineVersion'],
        $row['ValvesPerEngine'],
        $row['BedLength'],
        $row['BedLengthMetric'],
        $row['BedTypeName'],
        $row['BodyNumDoors'],
        $row['BrakeSystemName'],
        $row['BrakeABSName'],
        $row['BrakeTypeName'],
        $row['BrakeFront.BrakeTypeName'],
        $row['BrakeRear.BrakeTypeName'],
        $row['DriveTypeName'],
        $row['MfrBodyCodeName'],
        $row['SpringTypeFront.SpringTypeName'],
        $row['SpringTypeRear.SpringTypeName'],
        $row['SteeringTypeName'],
        $row['TransmissionTypeName'],
        $row['TransmissionNumSpeeds'],
        $row['TransmissionControlTypeName'],
        $row['TransmissionMfrCode'],
        $row['TransmissionMfr.MfrName'],
        $row['ElecControlled'],
        $row['WheelBase'],
        $row['WheelBaseMetric'],
        $row['VehicleTypeName']
    ));
}

I tried to echo one of the row values and then issue a die();, and the value echoed properly. I'm wondering if I'm missing something here... thanks!

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Brian Schroeter
  • 65
  • 1
  • 1
  • 5
  • Can you add a `var_dump($row)`? It looks like the array you're using doesn't have those keys in it. – andrewsi Aug 15 '13 at 15:36
  • I just dumped the row and it looks like since I'm grouping these fields, they're coming through like so -- [GROUP_CONCAT(DISTINCT(EngineDesignation.EngineDesignationName) SEPARATOR ', ')] in the dump. That being said, I think I can toy around with it now and figure it out. – Brian Schroeter Aug 15 '13 at 15:38
  • @BrianSchroeter - feel free to edit your question with the output of the var_dump, and an answer explaining what you did to fix it. – andrewsi Aug 15 '13 at 16:43

1 Answers1

-1

Before you fetch the array, you must be validate if the record has some value:

if (count($row) > 1) {
    //Fetch the items
}

The most common reason for this error, is because you are trying to use a data that doesn't exists.

Don't forget initialize your variables too.

$row = array()

Greetings

Beto Castillo
  • 867
  • 9
  • 16