Welcome Guest, Not a member yet? Register   Sign In
Problem with £ sign writing to MySQL (solved)
#1

(This post was last modified: 01-31-2016, 02:57 AM by JohnInMaldon.)

I'm executing a script which reads a text file with fgetcsv and uses query builder insert to write records.
All goes well, except that any string which has a £ symbol is truncated at that position.
The strings are are going into varchar, and phpMyAdmin lets me edit those characters in manually.
The varchar columns are specified to be utf8_general_ci.

Am I doing something wrong? Any assistance will be gratefully received!


The controller does :

            if (($handle = fopen($f, "r")) !== FALSE) {
                while(($data = fgetcsv($handle,1000,"\t")) !== FALSE) {
                    //file_put_contents('debug.txt',$data[2]."\r\n",FILE_APPEND);
                    $this->maint_model->rec_entries($data,$id);
                }
                fclose($handle);
            }

...and the put_file_contents verifies the data was read OK.

'rec_entries' looks like this:

    public function rec_entries($data,$id)
    {
        $data = array(
            'ind_id' => $id,
            'name' => $data[0],
            'subject' => $data[1],
            'event' => $data[2],
            'column' => $data[5],
            'doi' => $data[4],
            'page' => $data[3]
        );
        $this->db->insert('entries', $data);    // Make an entries table entry
        return;
    }
Reply
#2
Question 

Is there a better forum to post this sort of question?
Reply
#3
Rainbow 

I have found that I needed to explicitly convert the incoming data to the form I required. Obvious really, but I hadn't seen it done before!

So I have done things like:

                    $data = iconv("ISO-8859-1","UTF-8//IGNORE",$data);
and all is well.


Cheers!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB