Unable to upload excel file in php to mysql database










0















I have been trying to build a section in php file from where i can upload a excel files to the database.I did all the coding part but its not working.Data was not uploaded. So please help me.



Here is my code



This is the html part from where i will be uploading the excel file using enctype="multipart/form-data":



<div class="panel panel-primary">

<div class="panel-body">
<form method="POST" action="uploads.php?y='.$y.'&m='.$m.'" style="margin-left: 100px;" enctype="multipart/form-data">
<label for="fileToUpload">Select file to upload:
<br/> <small style="color: red;">*Please attach only .xls & .xlsx files.
</small>
</label>
<input class="form-control" type="file" name="fileToUpload" id="fileToUpload" style="width:300px; align: center;">
<br/>
<input class="btn btn-sm btn-info" type="submit" value="Upload File" name="submit">
</form>
</div>

</div>


PHP file uploads.php :



Data of the excel file is then sent to the php file to upload in the database, But this isn't working.



 require_once('vendor/php-excel-reader/excel_reader2.php');
require_once('vendor/SpreadsheetReader.php');

$y=$_GET['y'];
$m=$_GET['m'];
$year=$y.'_'.$m;

if (isset($_POST["submit"]))

$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];

if(in_array($_FILES["file"]["type"],$allowedFileType))


$targetPath = 'uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $targetPath);

$Reader = new SpreadsheetReader($targetPath);

$sheetCount = count($Reader->sheets());
for($i=0;$i<$sheetCount;$i++)

$Reader->ChangeSheet($i);

foreach ($Reader as $Row)

$date = "";
if(isset($Row[0]))
$date = mysqli_real_escape_string($con,$Row[0]);


$janmin = "";
if(isset($Row[1]))
$janmin = mysqli_real_escape_string($con,$Row[1]);


$janmax = "";
if(isset($Row[2]))
$janmax = mysqli_real_escape_string($con,$Row[2]);


$febmin = "";
if(isset($Row[3]))
$febmin = mysqli_real_escape_string($con,$Row[3]);


$febmax = "";
if(isset($Row[4]))
$febmax = mysqli_real_escape_string($con,$Row[4]);


$marmin = "";
if(isset($Row[5]))
$marmin = mysqli_real_escape_string($con,$Row[5]);


$marmax = "";
if(isset($Row[6]))
$marmax = mysqli_real_escape_string($con,$Row[6]);


$aprmin = "";
if(isset($Row[7]))
$aprmin = mysqli_real_escape_string($con,$Row[7]);


$aprmax = "";
if(isset($Row[8]))
$aprmax = mysqli_real_escape_string($con,$Row[8]);


$maymin = "";
if(isset($Row[9]))
$maymin = mysqli_real_escape_string($con,$Row[9]);


$maymax = "";
if(isset($Row[10]))
$maymax = mysqli_real_escape_string($con,$Row[10]);


$junemin = "";
if(isset($Row[11]))
$junemin = mysqli_real_escape_string($con,$Row[11]);


$junemax = "";
if(isset($Row[12]))
$junemax = mysqli_real_escape_string($con,$Row[12]);


$julymin = "";
if(isset($Row[13]))
$julymin = mysqli_real_escape_string($con,$Row[13]);


$julymax = "";
if(isset($Row[14]))
$julymax = mysqli_real_escape_string($con,$Row[14]);


$augmin = "";
if(isset($Row[15]))
$augmin = mysqli_real_escape_string($con,$Row[15]);


$augmax = "";
if(isset($Row[16]))
$augmax = mysqli_real_escape_string($con,$Row[16]);


$sepmin = "";
if(isset($Row[17]))
$sepmin = mysqli_real_escape_string($con,$Row[17]);


$sepmax = "";
if(isset($Row[18]))
$sepmax = mysqli_real_escape_string($con,$Row[18]);


$octmin = "";
if(isset($Row[19]))
$octmin = mysqli_real_escape_string($con,$Row[19]);


$octmax = "";
if(isset($Row[20]))
$octmax = mysqli_real_escape_string($con,$Row[20]);


$novmin = "";
if(isset($Row[21]))
$novmin = mysqli_real_escape_string($con,$Row[21]);


$novmax = "";
if(isset($Row[22]))
$novmax = mysqli_real_escape_string($con,$Row[22]);


$decmin = "";
if(isset($Row[23]))
$decmin = mysqli_real_escape_string($con,$Row[23]);


$decmax = "";
if(isset($Row[24]))
$decmax = mysqli_real_escape_string($con,$Row[24]);


if (!empty($date))
$query = "INSERT INTO `$year` (janmin,janmax,febmin,febmax,marmin,marmax,aprilmin,aprilmax,maymin,maymax,junemin,junemax,julymin,julymax,augmin,augmax,sepmin,sepmax,octmin,octmax,novmin,novmax,decmin,decmax,user_id,date)
VALUES ('$janmin','$janmax','$febmin','$febmax','$marmin','$marmax','$aprmin','$aprmax','$maymin','$maymax','$junemin','$junemax','$julymin','$julymax','$augmin','$augmax','$sepmin','$sepmax','$octmin','$octmax','$novmin','$novmax','$decmin','$decmax','$user_id','$date')";
$result = mysqli_query($con, $query);

if (! empty($result))
$type = "success";
$message = "Excel Data Imported into the Database";
echo $type.'<br />'.$message;

else
$type = "error";
$message = "Problem in Importing Excel Data";
echo $type.'<br />'.$message;




















share|improve this question






















  • Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

    – RiggsFolly
    Nov 13 '18 at 15:14











  • Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

    – RiggsFolly
    Nov 13 '18 at 15:14











  • But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

    – RiggsFolly
    Nov 13 '18 at 15:15












  • By the way mysqli_query() returns TRUE on success.. so no need for !empty()

    – B001ᛦ
    Nov 13 '18 at 15:17







  • 1





    So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

    – RiggsFolly
    Nov 13 '18 at 15:18
















0















I have been trying to build a section in php file from where i can upload a excel files to the database.I did all the coding part but its not working.Data was not uploaded. So please help me.



Here is my code



This is the html part from where i will be uploading the excel file using enctype="multipart/form-data":



<div class="panel panel-primary">

<div class="panel-body">
<form method="POST" action="uploads.php?y='.$y.'&m='.$m.'" style="margin-left: 100px;" enctype="multipart/form-data">
<label for="fileToUpload">Select file to upload:
<br/> <small style="color: red;">*Please attach only .xls & .xlsx files.
</small>
</label>
<input class="form-control" type="file" name="fileToUpload" id="fileToUpload" style="width:300px; align: center;">
<br/>
<input class="btn btn-sm btn-info" type="submit" value="Upload File" name="submit">
</form>
</div>

</div>


PHP file uploads.php :



Data of the excel file is then sent to the php file to upload in the database, But this isn't working.



 require_once('vendor/php-excel-reader/excel_reader2.php');
require_once('vendor/SpreadsheetReader.php');

$y=$_GET['y'];
$m=$_GET['m'];
$year=$y.'_'.$m;

if (isset($_POST["submit"]))

$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];

if(in_array($_FILES["file"]["type"],$allowedFileType))


$targetPath = 'uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $targetPath);

$Reader = new SpreadsheetReader($targetPath);

$sheetCount = count($Reader->sheets());
for($i=0;$i<$sheetCount;$i++)

$Reader->ChangeSheet($i);

foreach ($Reader as $Row)

$date = "";
if(isset($Row[0]))
$date = mysqli_real_escape_string($con,$Row[0]);


$janmin = "";
if(isset($Row[1]))
$janmin = mysqli_real_escape_string($con,$Row[1]);


$janmax = "";
if(isset($Row[2]))
$janmax = mysqli_real_escape_string($con,$Row[2]);


$febmin = "";
if(isset($Row[3]))
$febmin = mysqli_real_escape_string($con,$Row[3]);


$febmax = "";
if(isset($Row[4]))
$febmax = mysqli_real_escape_string($con,$Row[4]);


$marmin = "";
if(isset($Row[5]))
$marmin = mysqli_real_escape_string($con,$Row[5]);


$marmax = "";
if(isset($Row[6]))
$marmax = mysqli_real_escape_string($con,$Row[6]);


$aprmin = "";
if(isset($Row[7]))
$aprmin = mysqli_real_escape_string($con,$Row[7]);


$aprmax = "";
if(isset($Row[8]))
$aprmax = mysqli_real_escape_string($con,$Row[8]);


$maymin = "";
if(isset($Row[9]))
$maymin = mysqli_real_escape_string($con,$Row[9]);


$maymax = "";
if(isset($Row[10]))
$maymax = mysqli_real_escape_string($con,$Row[10]);


$junemin = "";
if(isset($Row[11]))
$junemin = mysqli_real_escape_string($con,$Row[11]);


$junemax = "";
if(isset($Row[12]))
$junemax = mysqli_real_escape_string($con,$Row[12]);


$julymin = "";
if(isset($Row[13]))
$julymin = mysqli_real_escape_string($con,$Row[13]);


$julymax = "";
if(isset($Row[14]))
$julymax = mysqli_real_escape_string($con,$Row[14]);


$augmin = "";
if(isset($Row[15]))
$augmin = mysqli_real_escape_string($con,$Row[15]);


$augmax = "";
if(isset($Row[16]))
$augmax = mysqli_real_escape_string($con,$Row[16]);


$sepmin = "";
if(isset($Row[17]))
$sepmin = mysqli_real_escape_string($con,$Row[17]);


$sepmax = "";
if(isset($Row[18]))
$sepmax = mysqli_real_escape_string($con,$Row[18]);


$octmin = "";
if(isset($Row[19]))
$octmin = mysqli_real_escape_string($con,$Row[19]);


$octmax = "";
if(isset($Row[20]))
$octmax = mysqli_real_escape_string($con,$Row[20]);


$novmin = "";
if(isset($Row[21]))
$novmin = mysqli_real_escape_string($con,$Row[21]);


$novmax = "";
if(isset($Row[22]))
$novmax = mysqli_real_escape_string($con,$Row[22]);


$decmin = "";
if(isset($Row[23]))
$decmin = mysqli_real_escape_string($con,$Row[23]);


$decmax = "";
if(isset($Row[24]))
$decmax = mysqli_real_escape_string($con,$Row[24]);


if (!empty($date))
$query = "INSERT INTO `$year` (janmin,janmax,febmin,febmax,marmin,marmax,aprilmin,aprilmax,maymin,maymax,junemin,junemax,julymin,julymax,augmin,augmax,sepmin,sepmax,octmin,octmax,novmin,novmax,decmin,decmax,user_id,date)
VALUES ('$janmin','$janmax','$febmin','$febmax','$marmin','$marmax','$aprmin','$aprmax','$maymin','$maymax','$junemin','$junemax','$julymin','$julymax','$augmin','$augmax','$sepmin','$sepmax','$octmin','$octmax','$novmin','$novmax','$decmin','$decmax','$user_id','$date')";
$result = mysqli_query($con, $query);

if (! empty($result))
$type = "success";
$message = "Excel Data Imported into the Database";
echo $type.'<br />'.$message;

else
$type = "error";
$message = "Problem in Importing Excel Data";
echo $type.'<br />'.$message;




















share|improve this question






















  • Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

    – RiggsFolly
    Nov 13 '18 at 15:14











  • Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

    – RiggsFolly
    Nov 13 '18 at 15:14











  • But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

    – RiggsFolly
    Nov 13 '18 at 15:15












  • By the way mysqli_query() returns TRUE on success.. so no need for !empty()

    – B001ᛦ
    Nov 13 '18 at 15:17







  • 1





    So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

    – RiggsFolly
    Nov 13 '18 at 15:18














0












0








0








I have been trying to build a section in php file from where i can upload a excel files to the database.I did all the coding part but its not working.Data was not uploaded. So please help me.



Here is my code



This is the html part from where i will be uploading the excel file using enctype="multipart/form-data":



<div class="panel panel-primary">

<div class="panel-body">
<form method="POST" action="uploads.php?y='.$y.'&m='.$m.'" style="margin-left: 100px;" enctype="multipart/form-data">
<label for="fileToUpload">Select file to upload:
<br/> <small style="color: red;">*Please attach only .xls & .xlsx files.
</small>
</label>
<input class="form-control" type="file" name="fileToUpload" id="fileToUpload" style="width:300px; align: center;">
<br/>
<input class="btn btn-sm btn-info" type="submit" value="Upload File" name="submit">
</form>
</div>

</div>


PHP file uploads.php :



Data of the excel file is then sent to the php file to upload in the database, But this isn't working.



 require_once('vendor/php-excel-reader/excel_reader2.php');
require_once('vendor/SpreadsheetReader.php');

$y=$_GET['y'];
$m=$_GET['m'];
$year=$y.'_'.$m;

if (isset($_POST["submit"]))

$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];

if(in_array($_FILES["file"]["type"],$allowedFileType))


$targetPath = 'uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $targetPath);

$Reader = new SpreadsheetReader($targetPath);

$sheetCount = count($Reader->sheets());
for($i=0;$i<$sheetCount;$i++)

$Reader->ChangeSheet($i);

foreach ($Reader as $Row)

$date = "";
if(isset($Row[0]))
$date = mysqli_real_escape_string($con,$Row[0]);


$janmin = "";
if(isset($Row[1]))
$janmin = mysqli_real_escape_string($con,$Row[1]);


$janmax = "";
if(isset($Row[2]))
$janmax = mysqli_real_escape_string($con,$Row[2]);


$febmin = "";
if(isset($Row[3]))
$febmin = mysqli_real_escape_string($con,$Row[3]);


$febmax = "";
if(isset($Row[4]))
$febmax = mysqli_real_escape_string($con,$Row[4]);


$marmin = "";
if(isset($Row[5]))
$marmin = mysqli_real_escape_string($con,$Row[5]);


$marmax = "";
if(isset($Row[6]))
$marmax = mysqli_real_escape_string($con,$Row[6]);


$aprmin = "";
if(isset($Row[7]))
$aprmin = mysqli_real_escape_string($con,$Row[7]);


$aprmax = "";
if(isset($Row[8]))
$aprmax = mysqli_real_escape_string($con,$Row[8]);


$maymin = "";
if(isset($Row[9]))
$maymin = mysqli_real_escape_string($con,$Row[9]);


$maymax = "";
if(isset($Row[10]))
$maymax = mysqli_real_escape_string($con,$Row[10]);


$junemin = "";
if(isset($Row[11]))
$junemin = mysqli_real_escape_string($con,$Row[11]);


$junemax = "";
if(isset($Row[12]))
$junemax = mysqli_real_escape_string($con,$Row[12]);


$julymin = "";
if(isset($Row[13]))
$julymin = mysqli_real_escape_string($con,$Row[13]);


$julymax = "";
if(isset($Row[14]))
$julymax = mysqli_real_escape_string($con,$Row[14]);


$augmin = "";
if(isset($Row[15]))
$augmin = mysqli_real_escape_string($con,$Row[15]);


$augmax = "";
if(isset($Row[16]))
$augmax = mysqli_real_escape_string($con,$Row[16]);


$sepmin = "";
if(isset($Row[17]))
$sepmin = mysqli_real_escape_string($con,$Row[17]);


$sepmax = "";
if(isset($Row[18]))
$sepmax = mysqli_real_escape_string($con,$Row[18]);


$octmin = "";
if(isset($Row[19]))
$octmin = mysqli_real_escape_string($con,$Row[19]);


$octmax = "";
if(isset($Row[20]))
$octmax = mysqli_real_escape_string($con,$Row[20]);


$novmin = "";
if(isset($Row[21]))
$novmin = mysqli_real_escape_string($con,$Row[21]);


$novmax = "";
if(isset($Row[22]))
$novmax = mysqli_real_escape_string($con,$Row[22]);


$decmin = "";
if(isset($Row[23]))
$decmin = mysqli_real_escape_string($con,$Row[23]);


$decmax = "";
if(isset($Row[24]))
$decmax = mysqli_real_escape_string($con,$Row[24]);


if (!empty($date))
$query = "INSERT INTO `$year` (janmin,janmax,febmin,febmax,marmin,marmax,aprilmin,aprilmax,maymin,maymax,junemin,junemax,julymin,julymax,augmin,augmax,sepmin,sepmax,octmin,octmax,novmin,novmax,decmin,decmax,user_id,date)
VALUES ('$janmin','$janmax','$febmin','$febmax','$marmin','$marmax','$aprmin','$aprmax','$maymin','$maymax','$junemin','$junemax','$julymin','$julymax','$augmin','$augmax','$sepmin','$sepmax','$octmin','$octmax','$novmin','$novmax','$decmin','$decmax','$user_id','$date')";
$result = mysqli_query($con, $query);

if (! empty($result))
$type = "success";
$message = "Excel Data Imported into the Database";
echo $type.'<br />'.$message;

else
$type = "error";
$message = "Problem in Importing Excel Data";
echo $type.'<br />'.$message;




















share|improve this question














I have been trying to build a section in php file from where i can upload a excel files to the database.I did all the coding part but its not working.Data was not uploaded. So please help me.



Here is my code



This is the html part from where i will be uploading the excel file using enctype="multipart/form-data":



<div class="panel panel-primary">

<div class="panel-body">
<form method="POST" action="uploads.php?y='.$y.'&m='.$m.'" style="margin-left: 100px;" enctype="multipart/form-data">
<label for="fileToUpload">Select file to upload:
<br/> <small style="color: red;">*Please attach only .xls & .xlsx files.
</small>
</label>
<input class="form-control" type="file" name="fileToUpload" id="fileToUpload" style="width:300px; align: center;">
<br/>
<input class="btn btn-sm btn-info" type="submit" value="Upload File" name="submit">
</form>
</div>

</div>


PHP file uploads.php :



Data of the excel file is then sent to the php file to upload in the database, But this isn't working.



 require_once('vendor/php-excel-reader/excel_reader2.php');
require_once('vendor/SpreadsheetReader.php');

$y=$_GET['y'];
$m=$_GET['m'];
$year=$y.'_'.$m;

if (isset($_POST["submit"]))

$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];

if(in_array($_FILES["file"]["type"],$allowedFileType))


$targetPath = 'uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $targetPath);

$Reader = new SpreadsheetReader($targetPath);

$sheetCount = count($Reader->sheets());
for($i=0;$i<$sheetCount;$i++)

$Reader->ChangeSheet($i);

foreach ($Reader as $Row)

$date = "";
if(isset($Row[0]))
$date = mysqli_real_escape_string($con,$Row[0]);


$janmin = "";
if(isset($Row[1]))
$janmin = mysqli_real_escape_string($con,$Row[1]);


$janmax = "";
if(isset($Row[2]))
$janmax = mysqli_real_escape_string($con,$Row[2]);


$febmin = "";
if(isset($Row[3]))
$febmin = mysqli_real_escape_string($con,$Row[3]);


$febmax = "";
if(isset($Row[4]))
$febmax = mysqli_real_escape_string($con,$Row[4]);


$marmin = "";
if(isset($Row[5]))
$marmin = mysqli_real_escape_string($con,$Row[5]);


$marmax = "";
if(isset($Row[6]))
$marmax = mysqli_real_escape_string($con,$Row[6]);


$aprmin = "";
if(isset($Row[7]))
$aprmin = mysqli_real_escape_string($con,$Row[7]);


$aprmax = "";
if(isset($Row[8]))
$aprmax = mysqli_real_escape_string($con,$Row[8]);


$maymin = "";
if(isset($Row[9]))
$maymin = mysqli_real_escape_string($con,$Row[9]);


$maymax = "";
if(isset($Row[10]))
$maymax = mysqli_real_escape_string($con,$Row[10]);


$junemin = "";
if(isset($Row[11]))
$junemin = mysqli_real_escape_string($con,$Row[11]);


$junemax = "";
if(isset($Row[12]))
$junemax = mysqli_real_escape_string($con,$Row[12]);


$julymin = "";
if(isset($Row[13]))
$julymin = mysqli_real_escape_string($con,$Row[13]);


$julymax = "";
if(isset($Row[14]))
$julymax = mysqli_real_escape_string($con,$Row[14]);


$augmin = "";
if(isset($Row[15]))
$augmin = mysqli_real_escape_string($con,$Row[15]);


$augmax = "";
if(isset($Row[16]))
$augmax = mysqli_real_escape_string($con,$Row[16]);


$sepmin = "";
if(isset($Row[17]))
$sepmin = mysqli_real_escape_string($con,$Row[17]);


$sepmax = "";
if(isset($Row[18]))
$sepmax = mysqli_real_escape_string($con,$Row[18]);


$octmin = "";
if(isset($Row[19]))
$octmin = mysqli_real_escape_string($con,$Row[19]);


$octmax = "";
if(isset($Row[20]))
$octmax = mysqli_real_escape_string($con,$Row[20]);


$novmin = "";
if(isset($Row[21]))
$novmin = mysqli_real_escape_string($con,$Row[21]);


$novmax = "";
if(isset($Row[22]))
$novmax = mysqli_real_escape_string($con,$Row[22]);


$decmin = "";
if(isset($Row[23]))
$decmin = mysqli_real_escape_string($con,$Row[23]);


$decmax = "";
if(isset($Row[24]))
$decmax = mysqli_real_escape_string($con,$Row[24]);


if (!empty($date))
$query = "INSERT INTO `$year` (janmin,janmax,febmin,febmax,marmin,marmax,aprilmin,aprilmax,maymin,maymax,junemin,junemax,julymin,julymax,augmin,augmax,sepmin,sepmax,octmin,octmax,novmin,novmax,decmin,decmax,user_id,date)
VALUES ('$janmin','$janmax','$febmin','$febmax','$marmin','$marmax','$aprmin','$aprmax','$maymin','$maymax','$junemin','$junemax','$julymin','$julymax','$augmin','$augmax','$sepmin','$sepmax','$octmin','$octmax','$novmin','$novmax','$decmin','$decmax','$user_id','$date')";
$result = mysqli_query($con, $query);

if (! empty($result))
$type = "success";
$message = "Excel Data Imported into the Database";
echo $type.'<br />'.$message;

else
$type = "error";
$message = "Problem in Importing Excel Data";
echo $type.'<br />'.$message;

















javascript php html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 15:13









Giant GibbonGiant Gibbon

41




41












  • Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

    – RiggsFolly
    Nov 13 '18 at 15:14











  • Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

    – RiggsFolly
    Nov 13 '18 at 15:14











  • But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

    – RiggsFolly
    Nov 13 '18 at 15:15












  • By the way mysqli_query() returns TRUE on success.. so no need for !empty()

    – B001ᛦ
    Nov 13 '18 at 15:17







  • 1





    So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

    – RiggsFolly
    Nov 13 '18 at 15:18


















  • Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

    – RiggsFolly
    Nov 13 '18 at 15:14











  • Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

    – RiggsFolly
    Nov 13 '18 at 15:14











  • But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

    – RiggsFolly
    Nov 13 '18 at 15:15












  • By the way mysqli_query() returns TRUE on success.. so no need for !empty()

    – B001ᛦ
    Nov 13 '18 at 15:17







  • 1





    So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

    – RiggsFolly
    Nov 13 '18 at 15:18

















Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

– RiggsFolly
Nov 13 '18 at 15:14





Error checking but if you cannot be bothered, Add ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); to the top of your script. This will force any mysqli_ errors to generate an Exception that you can see on the browser as well as normal PHP errors.

– RiggsFolly
Nov 13 '18 at 15:14













Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

– RiggsFolly
Nov 13 '18 at 15:14





Your script is wide open to SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either the MYSQLI_ or PDO API's

– RiggsFolly
Nov 13 '18 at 15:14













But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

– RiggsFolly
Nov 13 '18 at 15:15






But this isn't working. But that is not really any help to someone trying to provide remote support like we are. Tell us what is doing! Tell us what is in NOT doing! Show us any errors! Look at the log files to see if there are any errors!!! Then maybe we can helpp

– RiggsFolly
Nov 13 '18 at 15:15














By the way mysqli_query() returns TRUE on success.. so no need for !empty()

– B001ᛦ
Nov 13 '18 at 15:17






By the way mysqli_query() returns TRUE on success.. so no need for !empty()

– B001ᛦ
Nov 13 '18 at 15:17





1




1





So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

– RiggsFolly
Nov 13 '18 at 15:18






So @B001ᛦ means this line if (! empty($result)) { will not a reliable test of success OR failure

– RiggsFolly
Nov 13 '18 at 15:18













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284028%2funable-to-upload-excel-file-in-php-to-mysql-database%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284028%2funable-to-upload-excel-file-in-php-to-mysql-database%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20