Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DBD::mysql::st execute failed: Incorrect string value: 'xF0x9Fx98x9C' for column ...
- mysql> select version();
- +-------------------------+
- | version() |
- +-------------------------+
- | 5.7.13-0ubuntu0.16.04.2 |
- +-------------------------+
- mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA
- -> WHERE schema_name = "myDatabase";
- +----------------------------+
- | default_character_set_name |
- +----------------------------+
- | utf8mb4 |
- +----------------------------+
- mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
- -> information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
- -> WHERE CCSA.collation_name = T.table_collation
- -> AND T.table_schema = "myDatabase"
- -> AND T.table_name = "myTable";
- +--------------------+
- | character_set_name |
- +--------------------+
- | utf8mb4 |
- +--------------------+
- mysql> SELECT character_set_name FROM information_schema.`COLUMNS`
- -> WHERE table_schema = "myDatabase"
- -> AND table_name = "myTable"
- -> AND column_name = "myColumn";
- +--------------------+
- | character_set_name |
- +--------------------+
- | utf8mb4 |
- +--------------------+
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- use utf8;
- use Encode;
- use DBI;
- binmode STDOUT, ":utf8";
- #Here I connect using the parameter mysql_enable_utf8 (create database handle):
- my $dbh = DBI->connect('DBI:mysql:database=myDatabase;host=localhost','aUser','aPassword',{mysql_enable_utf8 => 1});
- #Prepare the statement (create statement handle):
- my $sth = $dbh->prepare('INSERT INTO `myTable` (`myColumn`) VALUES(?);');
- #This doesn't work:
- $sth->execute('😜');
- #This doesn't work either:
- $sth->execute(encode_utf8('😜'));
- #end processing:
- $dbh->disconnect();
- exit(0);
- DBD::mysql::st execute failed: Incorrect string value: 'xF0x9Fx98x9C' for column 'myColumn' at row 1 at myTestScript.pl line 16.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement