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

The Archive Base Latest Questions

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

I want to load data from several CSV documents in a database. The problem

  • 0

I want to load data from several CSV documents in a database.

The problem is that there is a table for a file, thus the table name has to be stored in a variable progressively updated by the loop. The tables are created, but after that the script fails; Nothing happens, my tables and their fields always have 0 lines.

I think that my idea is feasible, because some topics describe some tips in this way, but nothing works in my case.

This is my code that fails:

$query = "INSERT INTO". $name_of_the_file." (id, content) values (". $arrayGenre[0].",'".trim($arrayGenre[1])."')";  

where $name_of_the_file refers to the table created in the loop, referring ultimately to the file targeted by the loop.


Following your recommendations, I added a space and print the query by:

echo ("<br>". $query);

Here is an example for the first line. No offense for the xxx substitutions: these are nominative data.

INSERT INTO names.csv (id, url, content) values (1,'xxx_some_adressxxx,'agency: xxx')

I do not know enough PHP to say that it is the expected result, but that seems a good SQL request and the values are fine.

Here are the next lines of my script:

$mysqli->query($query);

and at the beginning of my script, the definition of $mysqli:

$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

New edit :

Well it was in fact SQL code which was badly written…

  • 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-07T18:55:11+00:00Added an answer on June 7, 2026 at 6:55 pm

    Try adding a space:

    $query = "INSERT INTO ". $name_of_the_file ...
    

    It’s always worth outputting your SQL via echo to make sure it looks like what you expect it to look like.

    Edit:

    INSERT INTO names.csv (id, url, content) values (1,'xxx_some_adressxxx,'agency: xxx')
    

    You need to add an apostrophe at the end of the second field:

    INSERT INTO names.csv (id, url, content) values (1,'xxx_some_adressxxx','agency: xxx')
    

    I’d also recommend that you look into things like PDO, to make your code more robust and more secure.

    You can also try pasting your SQL directly into the database, to see if it gives you an error.

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

Sidebar

Related Questions

I want to load data from MySql database to a HTTP form When I
I'm trying to load several cities' id, name, and positions from a MySQL table
I have a form with a DataGridView and I want to load data from
When I load data in my code-behind, I find that often I want to
I'm trying to create a windows form application that manipulates data from several tables
I've got a table in a database that stores log data by time. For
Hi I want to load the groups of a svg-file into several gtk pixbuffs/subpixbufs
I have a C++ application that loads lots of data from a database, then
I want to load some data from mysql into my cocoa application view before
I want to load data when the user drags the scroll bar to rhw

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.