dstobkpm908182 2015-09-07 18:08
浏览 28

PHP代码5.4需要更改为适用于5.3.10

Getting a blank screen with no errors and no code. I have php version 5.3.10 on my live server but the code was developed on a local computer with version 5.6.2. The code written below was written for latest version of PHP but the live server the page will sit on has the old version 5.3.10.

I need to know which PHP syntax below is new and needs to be backwards compatible.

// Triggered when the Export CSV button is clicked.
        if(isset($_POST["search_results"]) && isset($_POST["pub_results"]) ) {

    // Sets the value of the hidden field as a variable (the value will be the SQL query saved earlier)
          $results = $_POST['search_results'];
          $pubResults = $_POST['pub_results'];

          $query = $pubResults;

            // Performs the query again to get the results to export
          $r = mysqli_query($conn, $query)or die(mysql_error());

          if (!mysqli_num_rows($r)==0) {

                // Adds all of the results to the CSV file
           while ($row = mysqli_fetch_array($r)) {
            $pnfn = ucwords(strtolower($row[1]));
            $dataRow = [$row[0], $row[1], $row[2]];
        }
        $pnfn = preg_replace('/\s+/', '', $pnfn);
          $filename = $pnfn . "-" . $timestamp . ".csv";


    // Set headers for the CSV file
          header("Content-type: application/csv");


            header("Content-Disposition: attachment; filename=" . $filename);


          $csvHeader[] = "Pub Information:";
          fputcsv($fp, $csvHeader);

          $pubHeader = ["Outlet Code", "Pub Short Address", "Regional Code"];
          fputcsv($fp, $pubHeader);


            fputcsv($fp, $dataRow);


    }

    $csvHeader2[] = "Points Of Interest:";
    fputcsv($fp, $csvHeader2);

    // Query to retrieve all of the column names in the Entertainment table (are the same for the other 3) so that
    // they can appear at the top of the CSV file.
    $query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='enterprisepoi_342' AND TABLE_NAME='poi'";
    $r = mysqli_query($conn, $query)or die(mysql_error());

    // Adds the column names to an array
    while ($row = mysqli_fetch_array($r)) {

       $header[] = $row[0];

    } 
    array_push($header, "Distance");


    fputcsv($fp, $header);

    $query = $results;

    // Performs the query again to get the results to export
    $r = mysqli_query($conn, $query)or die(mysql_error());
     if (!mysqli_num_rows($r)==0) {

    // Adds all of the results to the CSV file
       while ($row = mysqli_fetch_array($r)) {
        $distance = number_format($row["distance"], 2, ".", "");
        $dataRow = [$row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $distance];
        fputcsv($fp, $dataRow);

    }
    // Exit so that the rest of the HTML in the document does not appear in the 
    // CSV file.
    exit;
    }

    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 关于无人驾驶的航向角
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了