$sql= "INSERT INTO restricted (name, id, citizenship, expires) VALUES ('".$rowData[0][0]."','".$rowData[0][1]."','".$rowData[0][2]."','".$rowData[0][3]."')";
Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[
^]
SQL Injection[
^]
SQL Injection Attacks by Example[
^]
PHP: SQL Injection - Manual[
^]
SQL Injection Prevention Cheat Sheet - OWASP[
^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[
^]
-----
Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
<?php
require('Classes/PHPExcel/IOFactory.php');
$servername="localhost";
$username="omri";
$password="1234";
$dbname="omri";
if(isset($_POST['upload'])){
$inputfilename= $_FILES['file']['tmp_name'] ;
$exceldata= array();
$conn= mysqli_connect($servername, $username, $password, $dbname);
if(!$conn){
die("connection failed: ".mysqli_connect_error());
}
try{
$inputfiletype= PHPExcel_IOFactory::identify($inputfilename);
$objReader= PHPExcel_IOFactory::createReader($inputfiletype);
$objPHPExcel= $objReader ->load($inputfilename);
}
catch(Exception $e)
{
die('error loading file "'.pathinfo($inputfilename, PATHINFO_BASENAME).'": '.$e->getMessage());
}
$sheet= $objPHPExcel->getSheet(0);
$highestrow= $sheet->getHighestRow();
$higestcolumn= $sheet->getHighestColumn();
for($row=1; $row<=$highestrow; $row++)
{
$rowData= $sheet->rangeToArray('A'. $row .':'. $higestcolumn . $row, NULL, TRUE, FALSE );
$sql= "INSERT INTO restricted (name, id, citizenship, expires) VALUES ('".$rowData[0][0]."','".$rowData[0][1]."','".$rowData[0][2]."','".$rowData[0][3]."')";
if(mysql_query($conn,$sql)){
$exceldata[]=$rowData[0];
}
else{
echo "Error: " . $sql . "<br>" . mysql_error($conn);
}
}
echo "<table border='1'>";
foreach($exceldata as $index => $excelraw)
{
echo "<tr>";
foreach($excelraw as $excelcolumn)
{
echo "<td>". $excelcolumn . "</td>";
}
echo "</tr>";
}
echo "</table>";
mysql_close($conn);
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Import Excel</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="upload" value="upload">
</form>
</body>
</html>
Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]