我已經設法編碼這個CSV文件,它運行良好..我得到的唯一問題是形式上的變量錯誤..我得到這個錯誤...注意:Undefined variable:data在C:\ XAMPP \ htdocs中\ helper.php(527):運行時創建的在線功能22將csv填充到數據庫中
如何解決這個錯誤嗎?這
這是我的示例代碼...
<form enctype="multipart/form-data" method="POST" action="" > CSV<input type="file" name="file" /> <input type="submit" value="submit" name="submit"/> </form> //connect to the database $connect = mysql_connect("localhost","root",""); mysql_select_db("test",$connect); //select the table if(isset($_POST['submit'])) { //get the csv file $file = $_FILES['file']['tmp_name']; $handle = fopen($file,"r"); //loop through the csv file and insert into database do { if ($data[0]) { mysql_query("INSERT INTO f38uj_zhgooglemaps_markers (title, addresstext, published, baloon, icontype, mapid) VALUES ( '".addslashes($data[0])."', '".addslashes($data[1])."', '".addslashes($data[2])."', '".addslashes($data[3])."', '".addslashes($data[4])."', '".addslashes($data[5])."' ) "); } } while ($data = fgetcsv($handle,1000,",","'")); } ?>
我注意到了,但我仍然剛開錯誤 – Mary
有可能直接使用數據庫服務器導入數據。 – Fanda
我的問題是我的公司需要從遠程位置導入,所以我需要創建標記...我在地圖上工作 – Mary