Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:55:37+00:00 2026-06-07T16:55:37+00:00

I am importing excel file to my database. While importing i get the error

  • 0

I am importing excel file to my database. While importing i get the error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ 999, , , 2009-02-03, 9, 133, 2, 0, 0, 0, 3, 1, 1, 1, 04/02/2009, 40816.0460995,’ at line 1
I did a echo for query and it is proper. But when i try to insert this into database, i get this error. Here is my database structure

CREATE TABLE `product` (
  `product_id` int(11) NOT NULL AUTO_INCREMENT,
  `model` varchar(64) COLLATE utf8_bin NOT NULL,
  `sku` varchar(64) COLLATE utf8_bin NOT NULL,
  `upc` varchar(12) COLLATE utf8_bin NOT NULL,
  `location` varchar(128) COLLATE utf8_bin NOT NULL,
  `quantity` int(4) NOT NULL DEFAULT '0',
  `stock_status_id` int(11) NOT NULL,
  `image` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `manufacturer_id` int(11) NOT NULL,
  `shipping` tinyint(1) NOT NULL DEFAULT '1',
  `price` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `points` int(8) NOT NULL DEFAULT '0',
  `tax_class_id` int(11) NOT NULL,
  `date_available` date NOT NULL,
  `weight` decimal(15,8) NOT NULL DEFAULT '0.00000000',
  `weight_class_id` int(11) NOT NULL DEFAULT '0',
  `length` decimal(15,8) NOT NULL DEFAULT '0.00000000',
  `width` decimal(15,8) NOT NULL DEFAULT '0.00000000',
  `height` decimal(15,8) NOT NULL DEFAULT '0.00000000',
  `length_class_id` int(11) NOT NULL DEFAULT '0',
  `subtract` tinyint(1) NOT NULL DEFAULT '1',
  `minimum` int(11) NOT NULL DEFAULT '1',
  `sort_order` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `date_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `viewed` int(5) NOT NULL DEFAULT '0',
  PRIMARY KEY (`product_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=50 ;

and code to import and insert into database

  <?php
require_once 'reader.php';
$Host = "localhost";
$User = "user";
$Password = "password";
$DBname = "test";
$Link = mysql_connect ($Host, $User, $Password) or die (mysql_error());
mysql_select_db($DBname);




if(isset($_POST['submit']))
{
    $filename = $_FILES['uploadedfile']['name'];


$TARGET_PATH = "uploads/";


//$filename = mysql_real_escape_string($filename);

$TARGET_PATH .= $filename;


if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$TARGET_PATH))

chmod($TARGET_PATH, 0777);

{ 


    $data = new Spreadsheet_Excel_Reader();
    $data->setOutputEncoding('CP1251');
    $data->read($TARGET_PATH);

$count=0;
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
            if($j==1){
                $product_id=$data->sheets[0]['cells'][$i][$j];
                    }

                    if($j==2){
                $model=$data->sheets[0]['cells'][$i][$j];
                    }

            if($j==3){
                $sku=$data->sheets[0]['cells'][$i][$j];
                    }
            if($j==4){
                $upc=$data->sheets[0]['cells'][$i][$j];
                    }       

            if ($j==5){
                $location=$data->sheets[0]['cells'][$i][$j];
                }
            if ($j==6){
                $quantity=$data->sheets[0]['cells'][$i][$j];
                    }       


            if ($j==7){
                $stock_status_id=$data->sheets[0]['cells'][$i][$j];
                     }
            if ($j==8){
                $image=$data->sheets[0]['cells'][$i][$j];
                }         
                if ($j==9){
                $manufacturer_id=$data->sheets[0]['cells'][$i][$j];
                }
                if ($j==10){
                $shipping=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==11){
                $shippingamount=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==12){
                $price=$data->sheets[0]['cells'][$i][$j];
                    }
                if ($j==13){
                $points=$data->sheets[0]['cells'][$i][$j];
                }       
                    if ($j==14){
                $tax_class_id=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==15){
                $date_available=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==16){
                $weight=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==17){
                $weight_class_id=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==18){
                $length=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==19){
                $width=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==20){
                $height=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==21){
                $length_class_id=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==22){
                $subtract=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==23){
                $minimum=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==24){
                $sort_order=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==25){
                $status=$data->sheets[0]['cells'][$i][$j];
                    }
                    if ($j==26){
                $date_added=$data->sheets[0]['cells'][$i][$j];
                    }
                if ($j==27){
                $date_modified=$data->sheets[0]['cells'][$i][$j];
                }
                if ($j==28){
                $viewed=$data->sheets[0]['cells'][$i][$j];
                }                           

        }
$count++;

$Query72 ="insert into product (product_id,model,sku,upc,location,quantity,stock_status_id,image, manufacturer_id, shipping, shippingamount, price, points, tax_class_id, date_available, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified,viewed) values('', '$model', '$sku', '$upc', '$location', $quantity, $stock_status_id, '$image', $manufacturer_id, $shipping, $shippingamount, $price, $points, $tax_class_id, $date_available, $weight, $weight_class_id, $length, $width, $height, $length_class_id, $subtract, $minimum, $sort_order, $status, $date_added, $date_modified, $viewed)";
echo $Query72;
mysql_query ($Query72) or die (mysql_error()); 
if (mysql_affected_rows() >= 1) {
    print("ROW $count - update successful!");} else {print("ROW $count - update failed!");
    }



        }
    }
    echo "Updated Successfully";
}

?>

Please help me why am getting this error and how can i resolve it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:55:40+00:00Added an answer on June 7, 2026 at 4:55 pm

    Use this

    $Query72 ="insert into product (product_id,model,sku,upc,location,quantity,stock_status_id,image, manufacturer_id, shipping, shippingamount, price, points, tax_class_id, date_available, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified,viewed) 
    values('', '".$model."', '".$sku."', '".$upc."', '".$location."', '".$quantity."','".$stock_status_id."', '".$image."', '".$manufacturer_id."', '".$shipping."', '".$shippingamount."', '".$price."', '".$points."', '".$tax_class_id."', '".$date_available."', '".$weight."', '".$weight_class_id."', '".$length."', '".$width."', '".$height."','".$length_class_id."','".$subtract."','".$minimum."','".$sort_order."', '".$status."','".$date_added."','".$date_modified."','".$viewed."')";
    

    May it help you.

    This error occurred because you are not using quotes properly. In your query date value must be in a single quote.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some questions about importing data from Excel/CSV File into SQL Server. Let
I'm importing data in a SQL Server 2008 database from excel file where the
I'm looking for the best method for importing csv or excel file to SQL
I am importing an excel sheet into my sql database. Everything works fine, but
I am importing massive amounts of data from Excel that have various table layouts.
While importing website through content porter, I am getting an error that names and
I'm importing data from a CSV file that comes from excel, but i can't
I'm importing an Excel file to SQL through ASP.NET and a certain column includes
I'm importing data from an excel file and I just noticed that some cells
I'm importing the contents of an Excel 2007 file into a MySQL database but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.