title: Function in PHP script causing a 502 Bad Gateway error
body: <p>There's a function in my script that suddenly causes a 502 Bad Gateway error when running trough PHPStorm. I've never had it before with similar scripts. When I comment it out, I've got no errors at all. How's that possible ?</p>
  
  <p>The script takes info from one excel and converts it to another.</p>
  
  <pre><code>public static function WJ_JewelsToExcel($array, $fileName) {
      $objPHPExcel = new PHPExcel();
      $objPHPExcel-&gt;setActiveSheetIndex(0);
      $rowCount = 2;
  
      foreach ($array as $row) {
          $sku = $row[0];
          $gender = $row[1];
          $jewelType = $row[2];
          $jewelType2 = $row[3];
          $metalType = $row[4];
          $metalColor = $row[5];
          $gemType = $row[6];
          $gemColor = $row[7];
          $description = $row[9];
          $brand = $row[10];
          $msrp = $row[11];
          $price = $row[12];
          $qty = $row[13];
          $url = $row[14];
          $name = $brand . ' ' . $sku;
          $finalGender = "";
  
          if ($gender == "Female") {
              $finalGender = "Women's";
          } elseif ($gender == "Male") {
              $finalGender = "Men's";
          } else {
              $finalGender = "Child";
          }
          for($categoryRow = 0 ; $categoryRow &lt; 2 ; $categoryRow++){
              if($categoryRow == 0){
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A' . $rowCount, $sku);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('C' . $rowCount, "Jewels");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('D' . $rowCount, "simple");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('E' . $rowCount, "Jewelry/" . $finalGender . "/" . $jewelType);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('F' . $rowCount, "Default Category");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('G' . $rowCount, "base");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('K' . $rowCount, $brand);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('W' . $rowCount, $description);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AA' . $rowCount, "No");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AC' . $rowCount, $gemColor);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AD' . $rowCount, $gemType);
  
                  switch ($finalGender){
                      case "Women's": $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AE' . $rowCount, "Women");break;
                      case "Men's": $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AE' . $rowCount, "Men");break;
                      default: $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AE' . $rowCount, "Child");
                  }
  
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AG' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AK' . $rowCount, $jewelType2);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AN' . $rowCount, $metalColor);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AO' . $rowCount, $metalType);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AU' . $rowCount, $msrp);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AV' . $rowCount, "Use config");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AW' . $rowCount, "Use config");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('AX' . $rowCount, $name);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BB' . $rowCount, "Product Info Column");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BD' . $rowCount, $price);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BE' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BH' . $rowCount, $description);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BN' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BO' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BU' . $rowCount, "4");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BY' . $rowCount, $qty);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('BZ' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CA' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CB' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CC' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CD' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CE' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CF' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CG' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CH' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CI' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CK' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CL' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CM' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CN' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CO' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CP' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CQ' . $rowCount, "1");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CR' . $rowCount, "0");
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('CS' . $rowCount, "0");
              }
  
              if($categoryRow == 1){
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('E' . $rowCount, "Brands/" . $brand);
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('F' . $rowCount, "Default Category");
              }
              $rowCount++;
          }
      }
      $objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
      $objWriter-&gt;save('D:\Websites\Utilities\PHPUtils\Export\\' . $fileName);
  }
  </code></pre>
  
  <p>Above is the script causing the error, and it's called from a main.</p>
  
  <pre><code>require_once(__DIR__ . './PHPExcel/ExcelUtil.php');
  require_once(__DIR__ . './SOAP/SoapUtil.php');
  
  $data = ExcelUtil::ExcelToArray("WJ\\Jewels\\all_jewels.csv");
  ExcelUtil::WJ_JewelsToExcel($data, "WJ\\Jewels\\all_jewels.csv");
  </code></pre>
  
  <p>PHP &amp; Interpreter are configured correctly.</p>