csvファイルをDBにインサートするシステムを作成しています。
最初の画面からcsvをアップした際に下のようなエラーが起きます
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
調べて見ると改行コードのエラーのようですがどこに開業があるといけないのかわかりません。ご教授お願いします。
/* トランザクション処理 */ $pdo->beginTransaction(); try { $fp = fopen($tmp_name, 'rb'); while (($row = fgetcsv($fp)) !== FALSE) { if ($row === array(null)) { // 空行はスキップ continue; } /*ここに"-"が格納されていた場合の処理を記載する*/ if($row[5] === '-'){ /*前日の同カラムの値を参照してインサートしたい*/ $sq = "SELECT * FROM DB名 WHERE SC = " . $row[0] . "ORDER BY date desc LIMIT 0,1"; $stm= $pdo->query($sq); foreach($stm as $st){ for ($i = 5; $i <= 25; $i++) { if(i !== 19 or i !== 22){ $row[i]=$st[i]; } } } } echo($row[1]); if (count($row) > 10000) { // カラム数が異なる無効なフォーマット throw new RuntimeException('Invalid column detected'); } $executed = $stmt->execute($row); } コード
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/17 00:51