雖然運行進口大量數據導入mysql PHP腳本,我遇到了以下錯誤:內存限制用盡
memory exhausted near ''$GPGGA','130735.000','60.15751','N','24.74303','E','1','05','1.6','8.7','M','35' at line 1
我現在之前,在我的PHP INI文件分配256M內存限制。迄今爲止,這種記憶已經足夠我的腳步,直到現在我還沒有遇到任何問題。我已經導入了大小爲1MB和2.84MB的文件,同時將內存限制保持在256MB。當我運行約1MB的文本文件時發生此錯誤。
我假定錯誤引用的內存是PHP內存限制。是否可以設置其他內存限制?我希望在解決這個問題上提出一些建議。非常感謝。
新編輯
...
...
if (is_array($inFile)) {
foreach($inFile as $inFileName) {
$newFilePath = $upload_directory."/".$inFileName;
if($inFileName != "")
$handle = fopen($newFilePath,"r");
$numlines =1;
$query = "INSERT INTO gga_raw_data(device_id, gga_date, nmea, gga_time, latitude, north, longitude, east, fixed_quality, no_of_satelites, hdop, altitude, meters, height_of_geoid, metres, check_sum, test_case_id) values";
while (($data = fgetcsv($handle)) !== FALSE)
{
$numlines++;
$myDay=substr($data[1], 0,2);
$myMonth=substr($data[1], 2,2);
$myYear=substr($data[1], 4,2);
$gga_date = convertToNiceDate($myDay, $myMonth, 2000+$myYear);
$longitude = convertToDegrees($data[6]);
$latitude = convertToDegrees($data[4]);
if (!isset($data[16])) {
$data[16] = '';
}
$query .="('$data[0]','$gga_date','$data[2]','$data[3]','$latitude','$data[5]','$longitude','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]', '$data[15]', '$data[16])',";
}
$query = substr($query, 0,-1);
我不希望啓動一個新的問題,因爲它仍然是在這個問題上。 我已經解決了「內存耗盡」的問題,但現在有一個MySQL查詢錯誤已經使我的生活相當悲慘,我需要幫助。
這是我的輸入數據從文本文件的樣本:
1,070610,$GPGGA,080323.460,6013.45368,N,02445.28396,E,1,04,4.6,18.3,M,35.0,M,,*67
1,070610,$GPGGA,080327.000,6013.44424,N,02445.31214,E,1,05,1.9,30.8,M,35.0,M,,*66
這不同於回聲$查詢結果:
INSERT INTO gga_raw_data(device_id, gga_date, nmea, gga_time, latitude, north, longitude, east, fixed_quality, no_of_satelites, hdop, altitude, meters, height_of_geoid, metres,check_sum) values('1','2010,06,07','$GPGGA','080323.460','60.22423','N','24.75473','E','1','04','4.6','18.3','M','35.0','M','')('1','2010,06,07','$GPGGA','080327.000','60.22407','N','24.7552','E','1','05','1.9','30.8','M','35.0','M','')
)('1','2010,06,07','$GPGGA','053416.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','053431.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','062929.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','080250.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','080305.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','080305.000','0','','0','','0','','','','','','','')('1','2010,06,07','$GPGGA','080320.000','0','','0','','0','','','','','','','')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('1','2010,06,07','$GPGGA','080327.000','60.22407','N','24.7552','E','1','05','1' at line 1
我已經開始注意到,最後一個變量來自輸入數據的「* 67」未被查詢解析。我不確定它是否因爲以*開頭而未被識別。
請表現出更多的情況下,也許一些代碼。那個錯誤信息來自哪裏?它不是PHP的默認「內存不足」消息,聽起來更像是來自mySQL – 2010-11-11 12:27:41
正在運行的腳本包含一個查詢,它運行一個查詢,但使用while循環執行多次插入。另一個補充只是2個功能隱蔽日期和2個領域。 Peharps你是對的。它應該來自mySQL – ibiangalex 2010-11-11 12:31:16
我正在運行一個wampserver,但我不知道你的意思,如果你可以顯示一些例子。 – ibiangalex 2010-11-11 14:21:06