php - no error message but all of data fail to import -


i want import data excel file phpmyadmin. use library excel_reader2. when click import button there no error message data fail import.

here code

<?php  include "excel_reader2.php";  mysql_connect("dbhost", "dbuser", "dbpass"); mysql_select_db("dbname");  $data = new spreadsheet_excel_reader($_files['userfile']['tmp_name']);  $baris = $data->rowcount($sheet_index=0);  $success = 0; $fail = 0;  ($i=2; $i<=$row; $i++) { $id = $id->val($i, 1); $name = $name->val($i, 2); $address = $address->val($i, 3);  $query = "insert student values ('$id', '$name', '$address')"; $result = mysql_query($query);   if ($result) $success++;  else $fail++; }  echo "<h3>import data finished</h3>"; echo "<p>sum of success data : ".$success."<br>"; echo "sum of fail data : ".$fail."</p>"; ?> 

and here result in browser

import data finished sum of success data : 0 sum of fail data : 100

please, me.. big thanks..

maybe wrong when datas excel. may try that:

$id = $data->val($i, 1); $name = $data->val($i, 2); $address = $data->val($i, 3); 

you start i=2 , var baris never used


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -