mysql - How to call functions from another php file? -


in short: uploading /var/tmp multiple excel files, convert them .csv(2 different converters .xls , .xlsx). resulting file, result.csv should inserted database. worked until decided allow upload multiple files simultaneously(adding multiple attribute html input tag). problem: data not inserted table

<?php // database connection goes here; include 'convertt2a.php'; if (isset($_post["submit"])) { $updir = "/var/tmp/result.xlsx"; $n= count($_files['rawexcel']['name']); ($i=0; $i<$n; $i++)    { $upfile = $updir.basename($_files['rawexcel']['name'][$i]); $ext = pathinfo ($_files['rawexcel']['name'][$i], pathinfo_extension); if(is_uploaded_file ($_files ["rawexcel"]["tmp_name"][$i])) {  move_uploaded_file ($_files["rawexcel"]["tmp_name"][$i], $updir); if ($ext == 'xlsx' ) {   exec("/usr/local/bin/cnvt   /var/tmp/result.xlsx      /var/tmp/result.csv "); } else   if ($ext == 'xls' ) {   exec("/usr/local/bin/xls2csv -x   /var/tmp/result.xls* -b windows-1251 -c /var/tmp/result.csv -a utf-8"); }   echo "file  uploaded , converted .csv ";   }  else {  echo "error uploading file ".$upfile;}  if (isset($_post['provider'])) { //select action perform on case of different providers if ($_post['provider']=='tele2altel'){echo t2a("tele2");} }   echo "cycle ".$i."ended here; </br>";  }}  else {echo "not isset post method";}   ?> 

t2a function:

function t2a ($string){  //opening .csv file, inserting table in samplebank tele2altel $row =0; if (($handle = fopen("/var/tmp/result.csv", "r"))!==false){ while (($data = fgetcsv($handle, 1000, ","))!==false) { $row ++; //we got data in $data[$i] array if ($row==4) {$idb=$data[2];} if ($row >6) { $da=$data[0]; $imei = $data[1]; $ab=$data[2];$ty = null; $du=$data[6]; $op = $data[3];$dir =$data[5]; $num= strlen($dir); if ($num>=28) {$ty= $dir; $dir=null;} if ($ab!==''){ $sql= "insert tele2altel(abonent,opponent, type, data, duration,     idbase, imei,direction)   values ('$ab','$op','$ty','$da','$du', '$idb','$imei','$dir')"; $res = mysqli_query($conn, $sql);} }} fclose($handle); } else {echo "unable read file";} $s = "successfully inserted db"; return $s; } 

my output: file uploaded , converted .csv

cycle ended here;

successfully inserted db, times(number of files uploaded)

i have checked seapartely .csv files, being converted correctly. thus, error in t2a function. appreciate help.

include file in it.

<?php include('yourfilename'); ?> 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -