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

  • Home
  • SEARCH
  • 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 7925595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:21:46+00:00 2026-06-03T18:21:46+00:00

I am trying to upload a .csv file and than save each row to

  • 0

I am trying to upload a .csv file and than save each row to a mysql db. So for each row in the .csv file, I would like to create a row in my mysql db. Excuse my english, but I hope you get what I mean.

I have got so far, that i am able to get the data from the first row:

$path   = $targetPath;
$row    = 1;

if (($handle = fopen($path, "r")) !== FALSE) {

    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {

        $row++;
        $dataEntries[] = $data ;

    }

    fclose($handle);

} else{

    echo("There has been an error parsing ".$csvname);

}

//Everything seems to be okay, we can save it
foreach($dataEntries as $line){

    $oName  = $line[0];
    $oUrl   = $line[1];
    $oType  = $line[2];
    $oDescr = $line[3];

    //If there is just one row in the csv file, Output: "string"
    //If there are more rows, than the output is "stringstring1string2"
    echo($oName);

}

UPDATE

Just to let every1 know: @Greg P ´s solution worked great, but I had to add LOCAL to the infile command, so that I could access the csv file that was uploaded to my server:

LOAD DATA LOCAL INFILE '$targetPath' INTO TABLE tableName FIELDS TERMINATED BY ';' (name,url,type,descr)
  • 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-03T18:21:49+00:00Added an answer on June 3, 2026 at 6:21 pm

    Why not use LOAD DATA INFILE, something like this:

    LOAD DATA INFILE 'filename.csv' 
    INTO TABLE filenames
    FIELDS TERMINATED BY ',' 
    (Name, Url, Type, Descr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload this CSV file onto my table in pgsql, but I'm
I'm trying to upload a 95 GB CSV file into a MySQL database (MySQL
I'm currently trying to upload a csv file to a database through simple html
I am trying to upload a single .csv file in ASP.NET MVC. In my
I was trying to upload a csv file to update a table in my
I am trying to upload a CSV file to Oracle database from my client
I am trying to upload a moderetly sized csv file to google app engine
I'm trying to upload csv file to index. When I do I'm getting an
I'm trying to import a very large .csv file (~4gb) into mysql. I was
i am trying to transfer file from user to my server and than upload

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.