PHP内爆不使用单引号?

I've searched for about the last hour regarding this issue, but its becoming quite annoying...

Anyways, I'm trying to insert data into a mysqli db, i've done this numerous times before but for some reason I cannot figure out what is going wrong...

<?php

require_once("../config/dbmetar.php");

$delimiter = ',';
$file = "metars.csv";
$db = new mysqli(DB_HOST_METAR, DB_USER_METAR, DB_PASS_METAR, DB_NAME_METAR);
$r = 0;

if (($handle = fopen($file, "r")) !== FALSE) {

while (($data = fgetcsv($handle, 5000, $delimiter)) !== FALSE) {

    if ($r >= 6) {

        foreach($data as $i => $content) { 

            $data[$i] = $db->real_escape_string($content);

        }

        echo "INSERT INTO metars VALUES('" . implode("','", $data) . "');" . "<br>";
        //$db->query("INSERT INTO metars VALUES('" . implode("','", $data) . "');" );

    }

    $r++;

}

fclose($handle);
}

?>

The main issue is with the insert into metars values... the values should all be comma delimited with single quotes around each field value...

Currently this is what the echo is exporting:

INSERT INTO metars VALUES('PAJZ 011132Z AUTO 1 3/4SM BR FEW009 BKN019 OVC026 08/07 A2959 RMK AO2 PWINO TSNO P0001,PAJZ,2013-07-01T11:32:00Z,59.73,-157.27,8.0,7.0,,,,1.75,29.589567,,,TRUE,TRUE,,,TRUE,,TRUE,BR,FEW,900,BKN,1900,OVC,2600,,,IFR,,,,,,0.01,,,,,,SPECI,82.0');

Any suggestions?

Var_dump($data) returned these:

array(1) { [0]=> string(238) "PAJZ 011132Z AUTO 1 3/4SM BR FEW009 BKN019 OVC026 08/07 A2959 RMK AO2 PWINO TSNO P0001,PAJZ,2013-07-01T11:32:00Z,59.73,-157.27,8.0,7.0,,,,1.75,29.589567,,,TRUE,TRUE,,,TRUE,,TRUE,BR,FEW,900,BKN,1900,OVC,2600,,,IFR,,,,,,0.01,,,,,,SPECI,82.0" } INSERT INTO metars VALUES('');
array(1) { [0]=> string(153) "CYOD 011131Z 18002KT 1/2SM FG FEW250 RMK CI0,CYOD,2013-07-01T11:31:00Z,54.4,-110.28,,,180,2,,0.5,,,,,,,,,,,FG,FEW,25000,,,,,,,LIFR,,,,,,,,,,,,SPECI,544.0" } INSERT INTO metars VALUES('');
array(1) { [0]=> string(276) "CYYD 011131Z AUTO VRB06KT 5SM -RA BR FEW007 BKN070 OVC084 15/14 A3005 RMK PRESRR PCPN 1.0MM PAST HR SLP173 DENSITY ALT 1900FT,CYYD,2013-07-01T11:31:00Z,54.82,-127.18,15.0,14.0,0,6,,5.0,30.050198,1017.3,,TRUE,,,,,,,-RA BR,FEW,700,BKN,7000,OVC,8400,,,MVFR,,,,,,,,,,,,SPECI,523.0" } 

This means $data has 1 item, because implode works just fine this way.

var_dump($data);

Please run the dump. Maybe you have wrong delimiter, so $data has one single element.

I try these codes :

$a = array('PAJZ 011132Z AUTO 1 3/4SM BR FEW009 BKN019 OVC026 08/07 A2959 RMK AO2 PWINO TSNO P0001','PAJZ', '2013-07-01T11:32:00Z','','a','b','');

echo implode("','", $a);

The result is : enter image description here

It works fine!

my php version is : PHP 5.3.19 (cli) (built: Apr 30 2013 21:16:28) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

and you can find this in php.nethttp://www.php.net/manual/zh/function.implode.php

So, check your php version !