-1

我在运行 PHP 脚本时收到以下错误。该脚本应该通过 JOIN 在数据库中进行一些映射,然后将结果导出到 CSV 文件。

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

与此相关的代码如下...

// 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']
    ));
}

我尝试回显其中一个行值,然后发出 die();,并且该值正确回显。我想知道我是否在这里遗漏了什么......谢谢!

4

1 回答 1

-1

在获取数组之前,您必须验证记录是否具有某些值:

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

此错误的最常见原因是因为您尝试使用不存在的数据。

不要忘记初始化你的变量。

$row = array()

问候

于 2013-08-15T15:37:15.340 回答