Excel date is changed to different date in mysql - php

I am trying to import the excel file to mysql database. I have got date and IMEI field in excel to import to database. But while importing to database my date is changd to different date and IMEI no is changed to exponential format. How can I resolve that problem.
here is the picture.
And here is the code.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "portal";
//$exceldata = array();
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
/** Set default timezone (will throw a notice otherwise) */
date_default_timezone_set('Asia/Kolkata');
include 'Classes2/PHPExcel/IOFactory.php';
if(isset($_FILES['file']['name'])){
// $file_name = $_FILES['file']['name'];
// $ext = pathinfo($file_name, PATHINFO_EXTENSION);
//Checking the file extension
$file_name = $_FILES['file']['tmp_name'];
$inputFileName = $file_name;
if(is_uploaded_file($inputFileName)){
// Read your Excel workbook
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());
}
//Table used to display the contents of the file
echo '<center><table style="width:50%;" border=1>';
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// Loop through each row of the worksheet in turn
for ($row = 2; $row <= $highestRow; $row++) {
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,
NULL, TRUE, FALSE);
//check whether member already exists in database with same email
$prevQuery = "SELECT id FROM activereport WHERE aIMEI = '".$rowData[0][1]."' ";
// $prevResult = $con->query($prevQuery);
$prevResult = mysqli_query($con,$prevQuery);
$count = mysqli_num_rows($prevResult);
if($count > 0){
// //update member data
$sql = " UPDATE activereport SET modelno= '".$rowData[0][0]."', dateOfActivation='" . $rowData[0][2] . "' WHERE aIMEI = '" .$rowData[0][1]."' ";
}
else{
$sql = " INSERT INTO activereport (modelno, aIMEI, dateOfActivation) VALUES ('".$rowData[0][0]."','".$rowData[0][1]."','".$rowData[0][2]."')";
}
if (mysqli_query($con, $sql)) {
$exceldata[] = $rowData[0];
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
}
echo '</table></center>';
//redirect to the listing page
header("Location: Import_Active_Data.php");
}
else{
echo '<p style="color:red;">Please upload valid</p>';
}
}
?>

One reason for this behavior could be the way excel stores dates: by counting the days since Jan 1, 1900. if you pass that as an argument to your sql query, it could do weird things.
Try converting the excel date to a string first and pass that to the sql query.
So, I'd change this block:
if($count > 0){
// //update member data
$sql = " UPDATE activereport SET modelno= '".$rowData[0][0]."', dateOfActivation='" . $rowData[0][2] . "' WHERE aIMEI = '" .$rowData[0][1]."' ";
}
else{
$sql = " INSERT INTO activereport (modelno, aIMEI, dateOfActivation) VALUES ('".$rowData[0][0]."','".$rowData[0][1]."','".$rowData[0][2]."')";
}
into this:
if($count > 0){
// Date-to-string conversion start
$exceldate = $rowData[0][2];
$phpdate = new DateTime();
$phpdate->setDate(1899, 12, 30);
$dateint = new DateInterval("P" . $exceldate . "D");
$phpdate->add($dateint);
$datestring = $phpdate->format("Y-m-d");
// Date-to-string conversion end
// //update member data
$sql = " UPDATE activereport SET modelno= '".$rowData[0][0]."', dateOfActivation='" . $datestring . "' WHERE aIMEI = '" .$rowData[0][1]."' ";
}
else{
$sql = " INSERT INTO activereport (modelno, aIMEI, dateOfActivation) VALUES ('".$rowData[0][0]."','".$rowData[0][1]."','".$datestring."')";
}
Instead of using the rowData[0][2] directly, this will convert the value of that Excel cell (2017-11-11 = 43050) into a php-string ('2017-11-11'), which you can then pass to the sql query.

Related

PHP Explode and updata data to each colomn in mysql database

I have a form where I want a user to upload one or more images. I've used only one file field for this. The issue is when I submit the form only the "itemImageOne" field will be update. But the echo part( echo $pieces[0], echo $pieces[1] ) is shows the correct result. Bellow is part of my code.
<?php
error_reporting(E_ALL & ~E_NOTICE);
#ini_set('post_max_size', '64M');
#ini_set('upload_max_filesize', '64M');
/* * *********************************************** */
// database constants
define('DB_DRIVER', 'mysql');
define('DB_SERVER', 'localhost');
define('DB_SERVER_USERNAME', 'root');
define('DB_SERVER_PASSWORD', '');
define('DB_DATABASE', 'ibs');
$dboptions = array(
PDO::ATTR_PERSISTENT => FALSE,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
try {
$DB = new PDO(DB_DRIVER . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $dboptions);
} catch (Exception $ex) {
echo $ex->getMessage();
die;
}
if (isset($_POST["add"])) {
// include resized library
//require_once('./php-image-magician/php_image_magician.php');
$msg = "";
$pieces = "";
$valid_image_check = array("image/gif", "image/jpeg", "image/jpg", "image/png", "image/bmp");
if (count($_FILES["user_files"]) > 0) {
$folderName = "uploads/";
//$sql = "UPDATE module_course SET itemImage='$filename' WHERE id=1";
//$sql = "UPDATE SET module_course(itemImage) VALUES (:img)";
//$stmt = $DB->prepare($sql);
for ($i = 0; $i < count($_FILES["user_files"]["name"]); $i++) {
if ($_FILES["user_files"]["name"][$i] <> "") {
$image_mime = strtolower(image_type_to_mime_type(exif_imagetype($_FILES["user_files"]["tmp_name"][$i])));
// if valid image type then upload
if (in_array($image_mime, $valid_image_check)) {
$ext = explode("/", strtolower($image_mime));
$ext = strtolower(end($ext));
$filename = rand(10000, 990000) . '_' . time() . '.' . $ext;
$filepath = $folderName . $filename;
$pieces = explode(" ", $filename);
$imageOne = $pieces[0];
$imageTwo = $pieces[1];
echo $pieces[0]."<br/>"; // piece1
echo $pieces[1]."<br/>"; // piece2
$sql = "UPDATE module_course SET itemImageOne = $imageOne, itemImageTwo = $date WHERE id='1'";
$stmt = $DB->prepare($sql);
if (!move_uploaded_file($_FILES["user_files"]["tmp_name"][$i], $filepath)) {
$emsg .= "Failed to upload <strong>" . $_FILES["user_files"]["name"][$i] . "</strong>. <br>";
$counter++;
} else {
$smsg .= "<strong>" . $_FILES["user_files"]["name"][$i] . "</strong> uploaded successfully. <br>";
/* * ****** insert into database starts ******** */
try {
$stmt->bindValue(":img", $filename);
$stmt->execute();
$result = $stmt->rowCount();
if ($result > 0) {
// file uplaoded successfully.
} else {
// failed to insert into database.
}
} catch (Exception $ex) {
$emsg .= "<strong>" . $ex->getMessage() . "</strong>. <br>";
}
/* * ****** insert into database ends ******** */
}
} else {
$emsg .= "<strong>" . $_FILES["user_files"]["name"][$i] . "</strong> not a valid image. <br>";
}
}
}
$msg .= (strlen($smsg) > 0) ? successMessage($smsg) : "";
$msg .= (strlen($emsg) > 0) ? errorMessage($emsg) : "";
} else {
$msg = errorMessage("You must upload atleast one file");
}
}
?>
Try
UPDATE module_course
SET itemImageOne = $imageOne, itemImageTwo = $imageTwo
WHERE id = '1'; # Changed
Changed - Edit 01
$stmt = $DB->prepare("UPDATE module_course
SET itemImageOne = ?, itemImageTwo = ?
WHERE id = 1");
$stmt->bindValue(1, $imageOne, PDO::PARAM_STR);
$stmt->bindValue(2, $imageTwo, PDO::PARAM_STR);
$stmt->execute();
Error Bcz of you are binding one parameter $stmt->bindValue(":img", $filename);

Not able to apply formula to the excel spreadsheet using phpexcel?

I am using PHPExcel in my php code to generate an excel report with a number to spreadsheets but i want to apply formula complete columns in those spreadsheets and i am using the following code but its just applying the same values to the complete column but i want the formula to run and give values depending on the each cell column G of my worksheet, and i want these resulting values in column Q.
Following is the complete code that i am using:
<?php
$dbhost= "localhost"; //your MySQL Server
$dbuser = "root"; //your MySQL User Name
$dbpass = "root"; //your MySQL Password
$dbname = "pyramid";
//your MySQL Database Name of which database to use this
$tablename = "peachtree"; //your MySQL Table Name which one you have to create excel file
// your mysql query here , we can edit this for your requirement
$tablename1 = "shipping";
$tablename2 = "embassies";
$tablename3 = "documentprocesses";
$tablename4 = "documentdetails";
$tablename5 = "documents";
$sql = "Select * from $tablename ";
$sql1= "Select * from $tablename1";
$sql2= "Select * from $tablename2";
$sql3= "Select filter1.docID,
filter1.salesOrderID,
IF(filter1.docSource='shipping', 'Shipping', 'Non-Shipping') AS 'Doc Type',
filter1.countryID,
DATE(filter1.docTimeStamp) AS 'Date Received',
IF(filter2.processStartDate IS NULL, 'OPEN',
DATE(filter2.processStartDate)) AS 'Date Shipped',
$tablename3.processCode,
$tablename3.destination,
$tablename3.processStartDate,
$tablename4.*,
filter1.docValue
FROM ( SELECT docID,
salesOrderID,
docSource,
docValue,
countryID,
docTimeStamp
FROM $tablename5
WHERE DATE(docTimeStamp) <= '2015-03-31' ) AS filter1
JOIN (
SELECT docID,
processStartDate
FROM $tablename3
WHERE processCode = 'SHPD'
AND( processStatus <> 'completed'
OR DATE(processStartDate) > '2015-03-31')
) AS filter2
ON filter1.docID = filter2.docID
LEFT JOIN (
SELECT *
FROM $tablename3
WHERE DATE(processStartDate) <= '2015-03-31'
AND processStartDate IS NOT NULL) AS $tablename3
ON $tablename3.docID = filter2.docID
LEFT JOIN $tablename4 ON $tablename4.docID = filter2.docID";
//create code for connecting to mysql
$Connect = #mysql_connect($dbhost, $dbuser, $dbpass)
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = #mysql_select_db($dbname, $Connect)
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//execute query
$result = #mysql_query($sql,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
$result1 = #mysql_query($sql1,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
$result2 = #mysql_query($sql2,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
$result3 = #mysql_query($sql3,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
error_reporting(E_ALL);
set_time_limit(0);
ini_set('memory_limit','2500M');
require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// Set the active Excel worksheet to sheet 0
$objPHPExcel->setActiveSheetIndex(0);
// Initialise the Excel row number
$rowCount = 1;
//start of printing column names as names of MySQL fields
$column = 'A';
for ($i = 0; $i < mysql_num_fields($result); $i++)
{
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, mysql_field_name($result,$i));
$column++;
}
//end of adding column names
//start while loop to get data
$rowCount = 2;
while($row = mysql_fetch_row($result))
{
$column = 'A';
for($j=0; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, $value);
$column++;
}
$rowCount++;
}
$objPHPExcel->getActiveSheet()->setTitle('peachtree');
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex(1);
$rowCount = 1;
//start of printing column names as names of MySQL fields
$column = 'A';
for ($i = 0; $i < mysql_num_fields($result1); $i++)
{
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, mysql_field_name($result1,$i));
$column++;
}
//end of adding column names
//start while loop to get data
$rowCount = 2;
while($row = mysql_fetch_row($result1))
{
$column = 'A';
for($j=0; $j<mysql_num_fields($result1);$j++)
{
if(!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, $value);
$column++;
}
$rowCount++;
}
$objPHPExcel->getActiveSheet()->setTitle('shipping');
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex(2);
$rowCount = 1;
//start of printing column names as names of MySQL fields
$column = 'A';
for ($i = 0; $i < mysql_num_fields($result2); $i++)
{
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, mysql_field_name($result2,$i));
$column++;
}
//end of adding column names
//start while loop to get data
$rowCount = 2;
while($row = mysql_fetch_row($result2))
{
$column = 'A';
for($j=0; $j<mysql_num_fields($result2);$j++)
{
if(!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, $value);
$column++;
}
$rowCount++;
}
$objPHPExcel->getActiveSheet()->setTitle('embassies');
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex(3);
$rowCount = 1;
//start of printing column names as names of MySQL fields
$column = 'A';
for ($i = 0; $i < mysql_num_fields($result3); $i++)
{
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, mysql_field_name($result3,$i));
$column++;
}
$column = 'Q';
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount,"SOS");
//end of adding column names
//start while loop to get data
$rowCount = 2;
while($row = mysql_fetch_row($result3))
{
$column = 'A';
for($j=0; $j<mysql_num_fields($result3);$j++)
{
if(!isset($row[$j]))
$value = NULL;
elseif ($row[$j] != "")
$value = strip_tags($row[$j]);
else
$value = "";
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount, $value);
$column++;
}
***$column = 'Q';
$objPHPExcel->getActiveSheet()->setCellValue($column.$rowCount,'=IF(column="SOS",15,0)');
$rowCount++;***
}
$objPHPExcel->getActiveSheet()->setTitle('documentdata');
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="results.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
Wading through your wall of code
=IF(column="SOS",15,0)
Doesn't look like a valid Excel formula to me. What is column? If it was an Excel named range, or a cell reference, then it would work; but as it stands it's nothing that would be valid in an Excel formula.
Your formula must be a valid Excel formula
EDIT
If you want to set a single cell to a value of 15 or 0 depending on whether any cell in column G contains the value "SOS", then an appropriate MS Excel formula for that would be
=IF(ISERROR(MATCH("SOS",G:G, 0)), 0, 15)
If you want to do this check on a row by row basis, then you'd set your formula to something like:
$objPHPExcel->getActiveSheet()
->setCellValue($column.$rowCount,'=IF(G'.$rowCount.'="SOS",15,0)');
EDIT #2
As a way of debugging, for row #2 (ie cell Q2) that formula should be
=IF(G2="SOS",15,0)
for row #3 (cell Q3) it should be
=IF(G3="SOS",15,0)
etc
Do some basic debugging to be sure that your PHP is concatenating the formula value correctly

Import CSV file data into MySQL table [duplicate]

This question already has answers here:
Insert and update CSV file data into MySQL table using PHP
(2 answers)
Closed 7 years ago.
I am inserting record from CSV file to MySQL table; if any record already exists update that record and insert other records and if there is no match of the record insert all records.
Here is my code
<?php
$connect = mysql_connect('localhost','root','root');
if (!$connect) {
die('Could not connect to MySQL: ' . mysql_error());
}
$cid =mysql_select_db('bizin490_devcredit',$connect);
define('CSV_PATH', '/home/ubc/Documents/');
$csv_file = CSV_PATH . "test.csv";
$csvfile = fopen($csv_file, 'r');
$theData = fgets($csvfile);
$i = 0;
while (!feof($csvfile)) {
$csv_data[] = fgets($csvfile, 1024);
$csv_array = explode(",", $csv_data[$i]);
$insert_csv = array();
$insert_csv['name'] = $csv_array[0];
$insert_csv['email'] = $csv_array[1];
$query = mysql_query("select name from test where name='" . $insert_csv['name'] . "'");
$count = mysql_num_rows($query);
if ($count == 0) {
$query = "INSERT INTO test(name,email)VALUES('" . $insert_csv['name'] . "','" . $insert_csv['email'] . "')";
$n = mysql_query($query, $connect);
} else {
$sql = "update test set email='".$insert_csv['email']."'";
//echo "<pre>";print_r($sql);
$qu = mysql_query($sql);
echo "<pre>";print_r($_POST);
}
$i++;
//die;
}
fclose($csvfile);
echo "File data successfully imported to database!!";
mysql_close($connect);
?>
Something like:
LOAD DATA INFILE '/home/ubc/Documents/test.csv'
REPLACE
INTO TABLE `test`
(name, email)

Creating a php file for translating the content dynamically

I have a database that has around 700 terms. I would just like to write a single php file called internationalize that would check the mysql database and return the proper translation. All the PHP variables have been setup and there is view that contains the translation of all the languages. There are about 11 languages. I have looked in a lot of places, but there isn't one that fits my situation. Any suggestions would be greatly appreciated.
if (!isset($_SESSION))
{
session_start();
}
if (isset($setup))
{
$lang=$_SESSION['setupLang'];
}
elseif (isset($_SESSION['lang']))
{
$lang=$_SESSION['lang'];
}
else
{
require("fetchMainConfig.php");
}
$lang_code = $lang;
//file_dir contains the language codes for example: il,fr,pt,ge and so on
$sql = "SELECT file_dir FROM `hydroserver_translation`.`language_file_dir`";
if($lang_code = $sql){
// What should go in here??? What is the best way to
// dynamically translate the database?
}
I am also attaching a copy of the database view. I plan to write the code is such a way that if there is no language translation the default translation is in english.
This is what I have done and it works. Thank you for your help!
<?php
//Connects to the database
$mysqlserver="servername";
$mysqlusername="langreader";
$mysqlpassword="readHSLlang#9";
$error=0;
$link=mysqli_connect($mysqlserver, $mysqlusername, $mysqlpassword) or $error=1;
$dbname = 'translation';
mysqli_select_db($link, $dbname) or $error=1;
if(!$error)
{//check which is the session language
$language = $lang_code;
//language file path
$file_path = "languages/" .$language. ".php";
//Check if file exists
$file_exists = file_exists($file_path);
if($file_exists){
// The file exists. Now just check when it was last time created.
$file_created_time = filemtime($file_path);
$timezone = date_default_timezone_set('UTC');
$current_time = time();
//Time lapse to check the difference between the current time and the last created time
$time_lapse = (abs($current_time-$file_created_time)/60/60);
//SQL statement to access the view from the database
$sql = "SELECT * FROM translation.translations_by_language";
$terms = mysqli_query($link, $sql);
//Will create a new file if it has been more than four hours
if($time_lapse >= '4.0'){
//Deleting the existing file to avoid any parsing errors
unlink($file_exists);
//Writing the new language_file
$lang_file= fopen("languages/" .$language. ".php","c+");
//Loops through the query and shows the translated terms
//and english terms if there are no translations for the term
$new_file = "<?php" . "\n ";
fwrite($lang_file, $new_file);
while($row = mysqli_fetch_array($terms)) {
if ($row[$language] != "")
fwrite($lang_file,$row['php_variable']. " = " . '"' . addslashes($row[$language]) . '"' . ";" . "\n ");
else
fwrite($lang_file,$row['php_variable']. " = " . '"' . addslashes($row['english_phrase']) . '"' . ";" . "\n ");
}
$last_line = "?>";
fwrite($lang_file, $last_line);
fclose($lang_file);
}
}
else{
// Creating a new file if the file doesn't exist
$sql = "SELECT * FROM hydroserver_translation.translations_by_language";
$terms = mysqli_query($link, $sql);
$lang_file= fopen("languages/" .$language. ".php","c+");
$new_file = "<?php" . "\n ";
fwrite($lang_file, $new_file);
while($row = mysqli_fetch_array($terms)) {
print_r($row);
if ($row[$language] != "")
//Provide the translation
fwrite($lang_file,$row['php_variable']. " = " . '"' . addslashes($row[$language]) . '"' . ";" . "\n ");
//If translation doesn't exist, just use the english phrase
else
fwrite($lang_file,$row['php_variable']. " = " . '"' . addslashes($row['english_phrase']) . '"' . ";" . "\n ");
}
$last_line = "?>";
fwrite($lang_file, $last_line);
fclose($lang_file);
//New language file succesfully created!!!!
}
}

Why can't I get my chunks of pdf into the mysql database?

So, here is the code I'm trying to use to break up a big pdf file into chunks and store it in my database. Is there any reason why it isn't working. I've worked all day to figure it out and have gone in circles a bunch. Would appreciate any help! Thanks!
<?
$username="something";
$password="something";
$database="something";
mysql_connect(localhost,$username,$password);
#mysql_select_db($database) or die("Unable to select database");
$STARTFILE = 1;
$ONFILE = "file" . $STARTFILE;
while (isset($HTTP_POST_FILES["$ONFILE"])) {
// Try!
$SrcPathFile = $HTTP_POST_FILES["$ONFILE"]["tmp_name"];
$SrcFileType = $HTTP_POST_FILES["$ONFILE"]["type"];
$DstFileName = $HTTP_POST_FILES["$ONFILE"]["name"];
clearstatcache();
$time = filemtime($SrcPathFile);
$storedate = date("Y-m-d H:i:s", $time);
// File Processing
if (file_exists($SrcPathFile)) {
// Insert into file table
$SQL = "insert into tbldocuments(Type,Description,Size,DateTime) values ('";
$SQL .= $SrcFileType . "', '" . $DstFileName . "', " . filesize($SrcPathFile);
$SQL .= ", '" . $storedate . "')";
if (!$RES = mysql_query($SQL, $linkid)) {
die("Failure on insert to file table!");
}
$fileid = mysql_insert_id($linkid);
// Insert into the filedata table
$fp = fopen($SrcPathFile, "rb");
while (!feof($fp)) {
// Make the data mysql insert safe
$binarydata = addslashes(fread($fp, 65535));
$SQL = "insert into tblDocumentChunks (documentId,chunkData) values (";
$SQL .= $fileid . ", '" . $binarydata . "')";
if (!mysql_query($SQL, $linkid)) {
die("Failure to insert binary inode data row!");
}
}
fclose($fp);
}
$STARTFILE ++;
$ONFILE = "file" . $STARTFILE;
}
echo "Upload Complete";
?>
First of all, $HTTP_POST_FILES has been deprecated for quite a while. Use $_FILES instead.
Second, you're declaring a variable $ONFILE, but you're not referencing it in the array.
Try removing the quotes ($ONFILE instead of "$ONFILE")

Categories