im trying to upload a video file into db and play it with videoJS player.
Everything ok but the video doesn't work and it shows loading icon and there it stops and the video is not played. does anyone can find out whats wrong? im using video js www.videojs.com
This is the index.php file:
<html>
<head>
<title>Video Upload System</title>
<link rel='stylesheet' href='style.css' />
</head>
<body>
<?php
include 'connect.php';
?>
<div id='box'>
<form method="post" enctype='multipart/form-data'>
<?php
if(isset($_FILES['video'])){
$name = $_FILES['video']['name'];
$type = explode('.', $name);
$type = end($type);
$size = $_FILES['video']['size'];
$random_name = rand();
$tmp = $_FILES['video']['tmp_name'];
if($type != 'mp4' && $type != 'MP4' && $type != 'avi'){
$message = "Video Format Not Supported";
}else{
move_uploaded_file($tmp, 'videos/'.$random_name.'.'.$type);
mysqli_query($connect, "INSERT INTO cinema VALUES ('','$name','$random_name.$type')");
$message = "Successfully Uploaded";
}
echo "$message <br/><br/>";
}
?>
Select Video: <br/>
<input type='file' name='video' />
<br><br>
<input type='submit' value='Upload Video'/>
</form>
</div>
<div id='box'>
<?php
$query = mysqli_query($connect, "SELECT id, name, url FROM cinema");
while ($run = mysqli_fetch_array($query)){
$video_id = $run['id'];
$video_name = $run['name'];
$video_url = $run['url'];
?>
<a href="view.php?video=<?php echo $video_url; ?>">
<div id='url'>
<?php echo $video_name; ?>
</div>
</a>
<?php
}
?>
</div>
</body>
</html>
and this is the view.php file:
<!doctype html>
<html lang="en">
<head>
<title>Video Upload System</title>
<link rel='stylesheet' href='style.css' />
<link href="http://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.2/video.js"></script>
</head>
<body>
<?php
include 'connect.php';
?>
<div id='box'>
<?php
$video = $_GET['video'];
?>
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="auto" width="640" height="264"
poster="http://video-js.zencoder.com/oceans-clip.png"
data-setup='{"example_option":true}'>
<source src="<?php echo $video; ?>" type="video/mp4">
</video>
</div>
</body>
</html>
You can download the latest videojs(zip) player here: http://www.videojs.com/
Extract the zip file and use the demo.html you probably need to build in autoplay = yes, or something like that.
<html>
<head>
<link href="http://vjs.zencdn.net/4.11/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.11/video.js"></script>
</head>
<body>
<body>
<?php
if(isset($_FILES['video'])){
$name = $_FILES['video']['name'];
$type = explode('.', $name);
$type = end($type);
$size = $_FILES['video']['size'];
$random_name = rand();
$tmp = $_FILES['video']['tmp_name'];
if($type != 'mp4' && $type != 'MP4' && $type != 'avi'){
$message = "Video Format Not Supported";
}else{
move_uploaded_file($tmp, 'videos/'.$random_name.'.'.$type);
mysqli_query($connect, "INSERT INTO cinema VALUES ('','$name','$random_name.$type')");
$message = "Successfully Uploaded";
}
echo "$message <br/><br/>";
}
?>
<div id='box'>
<form method="post" enctype='multipart/form-data'>
Select Video: <br/>
<input type='file' name='video' />
<br><br>
<input type='submit' value='Upload Video'/>
</form>
<video id="MY_VIDEO_1" class="video-js vjs-default-skin" controls
preload="auto" width="640" height="264" poster="MY_VIDEO_POSTER.jpg"
data-setup="{}">
<source src="MY_VIDEO.mp4" type='video/mp4'>
<source src="MY_VIDEO.webm" type='video/webm'>
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video</p>
</video>
</body>
</html>
Related
I asked this question before but did not get any actual answers. I created a website for my wife's jewelry. She wants a product page for each style she makes (bracelets, necklaces, etc.).
I created the database with a category section that has all the different categories she makes. The only problem I have is I cannot get the information to show up on the product page. I get errors such as
Notice: Undefined variable: item_number in C:\xampp\htdocs\pinkys_pearls\bracelets.php on line 83.
Here is my code for the page:
<?php
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
?>
<?php
// Connect to the MySQL database
include_once("storescripts/connect_to_mysql.php");
$con = mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_errno());
exit();
//Initializing variable
$item_number = "item_number";
$description = "description";
$category = "category";
$price = "price";
$qty = "qty";
$sql = "SELECT category FROM products WHERE category='Bracelets';";
$result = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
// get all the product details
while($row = mysqli_fetch_assoc($result)); {
echo $item_number = $row["item_number"];
$price = $row["price"];
$desc = $row["description"];
$category = $row["category"];
}
}
else {
echo "Data to render this page is missing.";
exit();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Bracelets</title>
<meta charset="utf-8">
<meta http-equiv="x=UA-comparable" content="IE-edge">
<meta name="description" content="Pinky's Pearls is a website where one of a kind jewelry designed by Nichole <q>Nicki</q> can be seen and purchased">
<meta name="keywords" content="jewelry, beads, bracelets, rings, pendants, necklaces, pearls, crystal">
<meta name="viewpoint" content="width=device-width, initial-scale=1">
<meta name="author" content="samuel jaycox">
<link href="style.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="shortcut icon" type="image/png" href="pictures/pinky.png">
<script src="https://use.fontawesome.com/0c9491c5b9.js"></script>
</head>
<body>
<div align="center" id="wrapper">
<div id="banner-wrapper">
<!---Company Header-->
<header>
<div id="header">
<img class="bracelet_header" src="pictures/headers/bracelets.jpg" alt="Bracelets">
<audio autoplay="autoplay" loop="loop" id="background-music">
<source src="music/Albinoni-adagio-in-g-minor-acoustic-guitar.mp3" type="audio/mpeg">
<source src="music/Albinoni-adagio-in-g-minor-acoustic-guitar.wav" type="audio/wav">
</audio>
</div>
</header>
<!---end of Company Header-->
<br>
<?php include_once("templates/template_navigation.php"); ?>
<br>
<br>
<br>
<!--Start Comment page Body Content-->
<div id="body-content">
<div class="bracelet_body">
<table width="100%" border="2" cellspacing="0" cellpadding="15">
<tr>
<td width="19%" valign="top">
<img src="pictures/inventory/<?php echo $pid; ?>.png" width="142" height="188" alt="<?php echo $item_number; ?>" /><br />
View Full Size Image
</td>
<td width="81%" valign="top">
<h3><?php echo $item_number; ?></h3>
<p><?php echo "$".$price; ?>
<br /><br />
<?php echo $desc; ?>
<br />
</p>
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
<input class="button" type="submit" name="button" id="button" value="Add to Shopping Cart" />
</form>
</td>
</tr>
</table>
</div>
</div>
<!--end of Comment body-->
<?php include_once("templates/template_footer.php"); ?>
</body>
</html>
What can I do to fix this?
You are missing a closing curly bracket at a critical point -
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_errno());
exit();
// RIGHT HERE
//Initializing variable
$item_number = "item_number";
$description = "description";
$category = "category";
With out it, none of your variables are initialized, your SQL query is never run, etc.
Once you've fixed that, try again and if there are still related issues edit the question, otherwise start a new question for a new issue.
Been working on a product page for my wife's jewelry site. I added php from a tutorial and tried to run the page. None of the images including the header showed up along with the footer. They show up on every other page. None of the information product showed up either. the page says connection opened and i receive no errors. The navigation shows up along with some of the css but that is all.
Here is my code I am using.
<?php
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
?>
<?php
if (isset($_GET['id'])) {
// Connect to the MySQL database
include_once("storescripts/connect_to_mysql.php");
$con =
mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_errno());
exit();
} $id = preg_replace('#[^0-9]#i', '', $_GET['id']);
$sql = "SELECT * FROM products WHERE category='Bracelets';";
$result = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
// get all the product details
while($row = mysqli_fetch_assoc($result)); {
$item_number = $row["item_number"];
$price = $row["price"];
$desc = $row["description"];
$category = $row["category"];
}
} else {
echo "Data to render this page is missing.";
exit();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Bracelets</title>
<meta charset="utf-8">
<meta http-equiv="x=UA-comparable" content="IE-edge">
<meta name="description" content="Pinky's Pearls is a website where
one
of a kind jewelry designed by Nichole <q>Nicki</q> can be seen and
purchased">
<meta name="keywords" content="jewelry, beads, bracelets, rings,
pendants, necklaces, pearls, crystal">
<meta name="viewpoint" content="width=device-width, initial-scale=1">
<meta name="author" content="samuel jaycox">
<link href="style.css" rel="stylesheet">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<link rel="shortcut icon" type="image/png" href="pictures/pinky.png">
<script src="https://use.fontawesome.com/0c9491c5b9.js"></script>
</head>
<body>
<div align="center" id="wrapper">
<div id="banner-wrapper">
<?php
include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_bracelets.php");
?>
<br>
<?php include_once("templates/template_navigation.php"); ?>
<br>
<br>
<br>
<!--Start Comment page Body Content-->
<div id="body-content">
<div class="bracelet_body">
<table width="100%" border="2" cellspacing="0" cellpadding="15">
<tr>
<td width="19%" valign="top"><img src="pictures/inventory/<?php echo
$pid; ?>.png" width="142" height="188" alt="<?php echo $item_number; ?>"
/>
<br />
<a href="pictures/inventory/<?php echo $pid; ?>.png">View Full Size
Image</a></td>
<td width="81%" valign="top"><h3><?php echo $item_number; ?></h3>
<p><?php echo "$".$price; ?><br />
<br />
<?php echo $desc; ?>
<br />
</p>
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value="<?php echo $id; ?
>"
/>
<input class="button" type="submit" name="button" id="button"
value="Add to Shopping Cart" />
</form>
</td>
</tr>
</table>
</div>
</div>
<!--end of Comment body-->
<?php include_once('templates/template_footer.php'); ?>">
</body>
</html>
Please make sure your paths are right!
Try to change your links
<?php include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_bracelets.php"); ?>
<?php include_once("c:/xampp/htdocs/pinkys_pearls/templates/template_navigation.php"); ?>
as
<?php include_once("localhost/pinkys_pearls/templates/template_bracelets.php"); ?>
<?php include_once("localhost/pinkys_pearls/templates/template_navigation.php"); ?>
and make sure with your image paths, if folder varies you cannot get load the images.
I have a video folder that contains MP4 videos. My PHP code looks into that folder and gets the name of one video and populates an HTML5 video element with the name.
$fname = $files[0];
[0] In the php represents the first MP4 video. If i change this to [1] it will populate the video tag with the second mp4 video, and if I change it to [2] it will get the next MP4 video name.
This all works as I only have 3 MP4 videos in the folder. But what I need is a redirect if it can't find a video in the folder.
At the moment, if I take out one of the videos from the folder, I get a php error:
NOTICE: Undefined offset: 3 in C:\xampp\htdocs\video1.php on line 18.
<!DOCTYPE html>
<html>
<head>
<title>Tv Web Video1</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="scripts/jquery.cycle.all.min.js" type="text/javascript"></script>
</head>
<body bgcolor="#A9A9A9">
<div id="wrapper">
<div id="content">
<div>
<?php
$files = glob('videos/*.mp4'); // get all .mp4 files from folder
$fname = $files[0]; // get 1st filename
$ftext = ucwords(str_replace('_', ' ', basename($fname, '.mp4'))); // format text for display
?>
<video id="video" class="box" poster="poster.jpg" preload="metadata" controls muted width="100%"
max-width:500px; height="50%" max-height:500px; autoplay onended="window.location = '/video2.php';">
<source src="<?php echo $fname; ?>"/>
</video>
<div id="infobox" class="box">Video: '<b><?php echo $ftext; ?></b>'</div>
<ul id="playlist" class="box">
</div>
</div>
</body>
</html>
Use empty()
<!DOCTYPE html>
<html>
<head>
<title>Tv Web Video1</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="scripts/jquery.cycle.all.min.js" type="text/javascript"></script>
</head>
<body bgcolor="#A9A9A9">
<div id="wrapper">
<div id="content">
<div>
<?php
$files = glob('videos/*.mp4');
$fname = $files[0];
$ftext = ucwords(str_replace('_', ' ', basename($fname, '.mp4')));
if(!empty($files))
{
?>
<video id="video" class="box" poster="poster.jpg" preload="metadata" controls muted width="100%" autoplay onended="window.location = '/video2.php'">
<source src="<?php echo $fname; ?>"/>
</video>
<div id="infobox" class="box">Video: '<b><?php echo $ftext; ?></b>'</div>
<ul id="playlist" class="box">
</ul>
<?
}
else
{
header("Location: http://example.com/myOtherPage.php");
}
?>
</div>
</div>
</body>
</html>
I have the following script:
<?php
$userid = $_GET['user'];
// A list of permitted file extensions
$allowed = array('png', 'jpg', 'gif','zip');
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
if(!in_array(strtolower($extension), $allowed)){
echo '{"status":"error"}';
exit;
}
if(move_uploaded_file($_FILES['upl']['tmp_name'], '../../'.$userid.'/assets/'.$_FILES['upl']['name'])){
echo '{"status":"success"}';
echo ' '.$userid;
exit;
}
}
echo '{"status":"error"}';
echo ' '.$userid;
exit;
?>
The problem is in this line:
if(move_uploaded_file($_FILES['upl']['tmp_name'], '../../'.$userid.'/assets/'.$_FILES['upl']['name'])){
When I use this path - everything works fine and the upload is successful:
'../../assets/'.$_FILES['upl']['name']
or
'../assets/'.$_FILES['upl']['name']
or
'assets/'.$_FILES['upl']['name']
All of these three work fine - but when I add the VARIABLE from a GET (from the URL path), it does not work? I know the VARIABLE "userid" is being recognized because I am echoing out before and after the path and it displays on the screen. Also I DID set write permissions on all of the folders, as defined by the VARIABLE.
Any thoughts?
THIS WAS ADDED >>>>>> THIS IS THE FIRST FILE....
<?
$userid = $_GET['user'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Mini Ajax File Upload Form</title>
<!-- Google web fonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700" rel='stylesheet' />
<!-- The main CSS file -->
<link href="css/style.css" rel="stylesheet" />
</head>
<body>
<p style="text-align:center"><? echo $userid; ?></p>
<form id="upload" method="post" action="upload.php" enctype="multipart/form-data">
<div id="drop">
Drop Here
<a>Browse</a>
<input type="file" name="upl" multiple />
</div>
<ul>
<!-- The file uploads will be shown here -->
</ul>
</form>
<!-- JavaScript Includes -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.knob.js"></script>
<!-- jQuery File Upload Dependencies -->
<script src="js/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<!-- Our main JS file -->
<script src="js/script.js"></script>
</body>
</html>
THIS IS THE PROCESSING FILE....
<?php
$userid = $_GET['user'];
// A list of permitted file extensions
$allowed = array('png', 'jpg', 'gif','zip');
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
if(!in_array(strtolower($extension), $allowed)){
echo '{"status":"error"}';
exit;
}
// if(move_uploaded_file($_FILES['upl']['tmp_name'], '../../'.$userid.'/assets/'.$_FILES['upl']['name'])){
if(move_uploaded_file($_FILES['upl']['tmp_name'], '../../'.$userid.'/assets/'.$_FILES['upl']['name'])){
echo '{"status":"success"}';
echo ' '.$userid;
exit;
}
}
echo '{"status":"error"}';
echo ' '.$userid;
exit;
?>
Unless you're creating a subdirectory in ../../ for each and every user manually, you need to create the directory for that user before trying to move the files to it.
if(!file_exist("../../$userid/")
mkdir("../../$userid/");
... and then you can move your file to it.
The below is the code which i tried for importing file(excel/csv) into MYSQL Database using php. This imports only the files with .xls extension and not .xlsx
May i know whats the mess with the code, either we have to include any library into the code or any change should be made.
<!DOCTYPE html>
<?php
include 'connect.php';
include 'Excel/reader.php';
function uploadFile($fieldName, $fileType, $folderName, $name = "")
{
$flg = 0;
$MaxID = "";
$ext = "";
$uploadfile = "";
if (isset($fieldName) AND $fieldName['name'] != '')
{
$flg = 1;
$allowed_filetypes = $fileType;
$max_filesize = 1048576;
$filename = $fieldName['name'];
if ($name == "")
$MaxID = time() . time() . rand(1, 100);
else
$MaxID = $name;
$ext = substr($filename, strpos($filename, '.'), strlen($filename) - 1);
if($ext==".xlsx")
$ext=".xlsx";
if (!in_array($ext, $allowed_filetypes))
echo "<h1>The file you attempted to upload is not allowed...</h1>";
else if (filesize($fieldName['tmp_name']) > $max_filesize)
echo "<h1>The file you attempted to upload is too large...</h1>";
else
{
$uploadfile = $folderName . "/" . $MaxID . $ext;
if (move_uploaded_file($fieldName['tmp_name'], $uploadfile) == FALSE)
{
echo "<h1>Error in Uploading File...</h1>";
$MaxID = "";
}
else
$MaxID = $MaxID . $ext;
}
}
return $MaxID;
}
if(isset($_POST['submit']))
{
if($_FILES['csvFile']['name']!="")
{
$fileName=uploadFile($_FILES['excelFile'],array(".csv"),"excel_file");
$row=0;
if(($handle = fopen("test.csv".$fileName , "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$num = count($data);
//print_r($data);
$query="INSERT INTO dealer_tbl(firstname,lastname,email,phone)VALUES('".$data[0]."','".$data[1]."','".$data[2]."','".$data[3]."')";
mysql_query($query);
}
fclose($handle);
}
}
else if($_FILES['excelFile']['name']!="")
{
$fileName=uploadFile($_FILES['excelFile'],array(".xls",".xlsx"),"excel_file");
$data = new Spreadsheet_Excel_Reader();
$data->read('excel_file/'.$fileName);
for($i=1;$i<=$data->sheets[0]['numRows'];$i++)
{ $title=$data->sheets[0]['cells'][$i][1];
$firstname=$data->sheets[0]['cells'][$i][2];
$lastname=$data->sheets[0]['cells'][$i][3];
$mobile=$data->sheets[0]['cells'][$i][4];
$phone=$data->sheets[0]['cells'][$i][5];
echo $firstname."','".$lastname."','".$mobile."','".$phone;
$query="INSERT INTO dealer_tbl(title,firstname,lastname,email,phone)VALUES('".$title."','".$firstname."','".$lastname."','".$mobile."','".$phone."')";
mysql_query($query);
}
}
}
if(isset($_POST['delete']))
{
mysql_query("DELETE FROM StudentData");
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<link rel="stylesheet" href="master_net_effect.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/bootstrap-custom.css">
<!-- HTML5 Shim, for IE6-IE8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38395785-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!-- Navbar
================================================== -->
<div id="header"> <a id="con_logo_link" href="http://s672.t.en25.com/e/er?s=672& lid=3261&elq=00000000000000000000000000000000" target="_blank"><!-- logo --></a></div>
<div id="wrap">
<div class="container">
<div class="row">
<div class="span6" id="form-login">
<form class="form-horizontal well" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="upload_excel" enctype="multipart/form-data">
<fieldset>
<legend>Import Dealers List</legend>
<div class="control-group">
<div class="control-label">
<label>Select CSV File</label>
</div>
<div class="controls">
<input type="file" name="csvFile" class="input-large">
</div>
</div>
or
<div class="control-group">
<div class="control-label">
<label>Select Excel File</label>
</div>
<div class="controls">
<input type="file" name="excelFile" class="input-large">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" id="submit" name="submit" data-loading-text="Loading...">Upload</button>
</div>
</div>
</fieldset>
</form>
</div>
<div class="span3 hidden-phone"></div>
</div>
<form name="del" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div class="control-group">
<div class="controls">
<button type="submit" id="delete" name="delete" data-loading-text="Loading...">Delete Data</button>
</div>
</div>
</form>
<table class="table table-bordered">
<tr>
<th>Title</th>
<th>First Name</th>
<th>Last Name</th>
<th>Mobile</th>
<th>Phone</th>
</tr>
<?php
$res=mysql_query("SELECT * FROM dealer_tbl");
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['firstname']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['phone']; ?>..
The Spreadsheet_Excel_Reader class certainly reads only XLS file.
If you want to read XLSX, try PhpExcel. This library can be extremely powerful.
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
include 'PHPExcel/IOFactory.php';
$inputFileName = 'your_file_to_import.xlsx';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
die('Error loading file :' . $e->getMessage());
}
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
print_r($sheetData);
you can try this it work for me: https://github.com/abdo0147/x2m this can read your xlsx file and give you a php file that will insert exel data to mysql and will give you a file to test if your data was inserted correctly.