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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:12:03+00:00 2026-06-08T04:12:03+00:00

I have a .csv file that I need to upload to the database. There

  • 0

I have a .csv file that I need to upload to the database. There is already an existing PHP script, that parses that data and inserts it into several database tables and this has been working fine. The latest csv file is giving me errors.

I cant get myself to fix this. This is simple English Text with no special characters but I keep getting errors on certain rows.

This is an example of one such row

It is an investment strategy that aims to balance risk and reward

This is the error I get while uploading

ERROR=1366-Incorrect string value: '\xA0strat...' for column 'question' at row 1

The table charset is UTF-8 and the column question is of type TEXT

I’m running the PHP script on Windows command prompt – I have a feeling it has something to do with that. But on all previous occasions, for other CSV files – the php script was running on Windows itself.

Now when I type the above English text in notepad and insert it in CSV file – it works fine – but I have over 500 rows that are giving this error and I cannot keep typing each line in notepad and then pasting it in CSV.

*** EDIT *********
This is the error producing code

foreach($question_array as $question) 
{
   //INSERT QUESTION  table
   mysql_query("INSERT INTO adl_question (question) VALUES ('".$question."')",$con);
   echo 'ERROR='.mysql_errno($con).'-'.mysql_error($con);
   $question_id = mysql_insert_id();
}

Any insights
Thanks

  • 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-08T04:12:05+00:00Added an answer on June 8, 2026 at 4:12 am

    I ran into this problem while doing data conversion recently. What you need to do is use iconv to read it explicitly as WINDOWS-1250 (or whatever character encoding the ‘bad’ text is) and then convert back to UTF-8.

    <?php 
    $string = iconv('windows-1250', 'utf-8', $badString);
    ?>
    

    See https://www.php.net/manual/en/function.iconv.php for more information.

    If you need to do this for an entire file, you can use this function (that I did not write):

    <?php 
    function utf8_fopen_read($fileName) {
        $fc = iconv('windows-1250', 'utf-8', file_get_contents($fileName));
        $handle=fopen("php://memory", "rw");
        fwrite($handle, $fc);
        fseek($handle, 0);
        return $handle;
    }
    ?>
    

    And then implement it as so:

    <?php 
    if (($handle = utf8_fopen_read("mycsv.csv")) !== FALSE) {
        
        while($file = fgetcsv($handle)) {
            $csv[] = $file;
        }
        
        foreach($csv as $row) {
            // run insert here
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data from a CSV file that's already loaded into memory. So I
I have a .csv file that has data in a column, I need that
I have a .csv file that contains data for only certain columns in a
I have a number of images and a CSV data file that I want
I have data stored in a csv file that looks like this: Date,BLOCK,,Wood,Miscellaneous,,Totals,MO Saturday,4055-RU,4055-AR,4091,1139,1158,,100
I have a CSV file with records that need to be sorted and then
I have a simple .csv file that has that I want to extract data
I have a CSV file listing items that I need to store within the
I have a csv file that contains a location field. I need to import
I have a simple 3 column csv file that i need to use python

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.