Hello guys I am going to upload my excel to sql but while i upload i get this error
Notice: Only variables should be passed by reference in C:\wamp64\www\invoic4\index.php on line 6
and this is index.php file
<?php
$connect = mysqli_connect("localhost", "root", "", "invoice4");
$output = '';
if(isset($_POST["import"]))
{
$extension = end(explode(".", $_FILES["excel"]["name"]));
$allowed_extension = array("xls", "xlsx", "csv");
if(in_array($extension, $allowed_extension))
{
$file = $_FILES["excel"]["tmp_name"];
include("PHPExcel/IOFactory.php");
$objPHPExcel = PHPExcel_IOFactory::load($file);
$output .= "Data Inserted<br>";
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$highestRow = $worksheet->getHighestRow();
for($row=2; $row<=$highestRow; $row++)
{
$output .= "";
$docno = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(0, $row)->getValue());
$importaction = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(1, $row)->getValue());
$query = "INSERT INTO invoice_table(docno, importaction) VALUES ('".$docno."', '".$importaction."')";
mysqli_query($connect, $query);
$output .= '';
$output .= '';
$output .= '';
}
}
$output .= '<table class="table table-bordered"><tbody><tr><td>'.$docno.'</td><td>'.$importaction.'</td></tr></tbody></table>';
}
else
{
$output = 'Invalid File';
}
}
?>
<title>Import Excel to Mysql using PHPExcel in PHP
body
{
margin:0;
padding:0;
background-color:#f1f1f1;
}
.box
{
width:1100px;
border:1px solid #ccc;
background-color:#fff;
border-radius:5px;
margin-top:100px;
}
<div class="container box">
<h3 align="center">Import Excel to Mysql using PHPExcel in PHP</h3><br>
Select Excel File
<br>
<br>
<br>
<?php
echo $output;
?>
</div>
What I have tried:
I do not know that is wrong with line 6