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 8976581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:10:50+00:00 2026-06-15T19:10:50+00:00

I am trying to import data from csv file, which has the following format:

  • 0

I am trying to import data from csv file, which has the following format:

173,antony,xds1079,Antony,Pran,Pran Antony,,452522252,,,,antpran@hotmail.com,,,,,Yes,Yes,No,pricelist.xls
18,john,smithison22,John,Smith,Smith Jon,,545455726,,,,johnsmith01@in.com,,,,,Yes,Yes,No,pricelist.xls
22,nikolas,Brand44eBerg,Nikolas,Brandeberg,Brandeberg and sons ,,454554552,,,,brand88@freemail.co.uk,,,,,Yes,Yes,No,pricelist.xls

When inserted it in mySQL, the last field in the first row, contained both pricelist.xls and 18. But the 18 should go in the next row, since it is the id field.

Here is the php code that I used:

if ($_FILES[csv][size] > 0) {

//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");


//loop through the csv file and insert into database
do {
    if ($data[0]) {
        mysql_query("INSERT INTO customers_tmp (id,username, password, firstname, lastname, companyname, companyposition, phone1, phone2, mobilephone, fax, email, address, afm, doy, website, active, wholesaling , wholesaling_bulk , pricecatalog) VALUES
            (
                '".addslashes($data[0])."',
                '".addslashes($data[1])."',
                '".addslashes($data[2])."',
                '".addslashes($data[3])."',
                '".addslashes($data[4])."',
                '".addslashes($data[5])."',
                '".addslashes($data[6])."',
                '".addslashes($data[7])."',
                '".addslashes($data[8])."',
                '".addslashes($data[9])."',
                '".addslashes($data[10])."',
                '".addslashes($data[11])."',
                '".addslashes($data[12])."',
                '".addslashes($data[13])."',
                '".addslashes($data[14])."',
                '".addslashes($data[15])."',
                '".addslashes($data[16])."',
                '".addslashes($data[17])."',
                '".addslashes($data[18])."',
                '".addslashes($data[19])."'                                                                                                                                                                                                                                      
            )
        ");
    }
} while ($data = fgetcsv($handle,1000,",","'"));
//

//redirect
header('Location: import.php?success=1'); die;

}

Does anyone know what I should do so the id can go in next line and not in the last field?

  • 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-15T19:10:51+00:00Added an answer on June 15, 2026 at 7:10 pm

    In case that someone else may need this solution, here is how I solved my problem:

    ini_set('auto_detect_line_endings', true);
    

    Regards,Zoran

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

Sidebar

Related Questions

I'm trying to import data from a csv file following the example given by
I am trying to import data from a CSV file to a SQL Server
I'm streaming data from a CSV file and trying to import it to SQL
I'm trying to import data from a .csv file into a Postgres 9.2 database
I'm trying to import data into a table from a .csv file, but mysql
I'm trying to import some data (using oracle sql developer) from a .csv file
I'm trying to import a csv (that is a data extract from a SQL
I am trying to import data from excel file (.xlsx) into sql database, my
I’m trying to import fixed width data from text file into SQL Server Express
I am trying to import a csv file to insert data into an existing

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.