|
 |
|
๊ช่วยหน่อยคะ !!!!! Upload text file เข้า MySQL แล้วข้อมูลเข้าไม่ครบ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
if(isset($_POST["Import"]))
{
$filename = $_FILES['file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if($ext != "txt" ) {
echo 'Upload File error';
}
else
{
echo 'Upload File complete';
$filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
while(!feof($file))
{
$data = explode("\t", fgets($file));
$ASSET_NUMBER = $data[0];
$ASSET_COMPCD = $data[1];
$ASSET_PLANT = $data[2];
$COSTCENTER = $data[3];
$ACQUISITION_DATE = $data[4];
$DESCRIPTION = $data[5];
$ACQUIS_VAL = $data[6];
$ACCUM_DEP = $data[7];
$BOOK_VAL = $data[8];
$ASST_NO = $data[9];
$ASST_NAME = $data[10];
$LOCATION = $data[11];
$STATUS = $data[12];
$str_query = "INSERT INTO `temp` (ASSET_NUMBER, ASSET_COMPCD, ASSET_PLANT, COSTCENTER, ACQUISITION_DATE, DESCRIPTION, ACQUIS_VAL, ACCUM_DEP, BOOK_VAL, ASST_NO, ASST_NAME, LOCATION, STATUS)
VALUES ('$ASSET_NUMBER', '$ASSET_COMPCD', '$ASSET_PLANT', '$COSTCENTER', '$ACQUISITION_DATE', '$DESCRIPTION', '$ACQUIS_VAL', '$ACCUM_DEP', '$BOOK_VAL', '$ASST_NO', '$ASST_NAME', '$LOCATION', '$STATUS')";
$result = mysql_query($str_query,$connection);
echo '<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">';
echo '<script language="javascript">';
echo 'alert("บันทึกข้อมูลเรียบร้อย")';
echo '</script>';
echo'<script>window.location="upload.php";</script>';
}
}else
{
echo '<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">';
echo '<script language="javascript">';
echo 'alert("ไม่สามารถบันทึกข้อมูลได้ ")';
echo '</script>';
echo'<script>window.location="upload.php";</script>';
}
fclose($file);
}
}
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, CakePHP

|
|
 |
 |
 |
 |
Date :
2016-03-10 11:41:56 |
By :
mayrizzaa |
View :
1032 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
echo $data;
ดู Query แล้วค่าอะไรไม่ออก ก็ไล่ดูต้นตอครับ
|
 |
 |
 |
 |
Date :
2016-03-10 12:46:58 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ออกเป็น Array อ่าคะ สรุปนะคะ ว่าข้อมูลทั้งหมดมันมี 20000 Row แต่ข้อมูลที่เข้าไปมันมีแค่ 1000 Row

|
 |
 |
 |
 |
Date :
2016-03-10 13:03:04 |
By :
mayrizzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือข้อมูลที่มันเอาเข้าไป ไม่ครบ ไม่ทราบว่าต้องแก้ยังไงคะ
|
 |
 |
 |
 |
Date :
2016-03-10 13:06:08 |
By :
mayrizzaa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo $sql ครับ มันทำทุก Rows หรือเปล่า
|
 |
 |
 |
 |
Date :
2016-03-11 09:28:59 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|