Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. DBD::mysql::st execute failed: Incorrect string value: 'xF0x9Fx98x9C' for column ...
  2.  
  3. mysql> select version();
  4. +-------------------------+
  5. | version() |
  6. +-------------------------+
  7. | 5.7.13-0ubuntu0.16.04.2 |
  8. +-------------------------+
  9.  
  10. mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA
  11. -> WHERE schema_name = "myDatabase";
  12. +----------------------------+
  13. | default_character_set_name |
  14. +----------------------------+
  15. | utf8mb4 |
  16. +----------------------------+
  17.  
  18. mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
  19. -> information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
  20. -> WHERE CCSA.collation_name = T.table_collation
  21. -> AND T.table_schema = "myDatabase"
  22. -> AND T.table_name = "myTable";
  23. +--------------------+
  24. | character_set_name |
  25. +--------------------+
  26. | utf8mb4 |
  27. +--------------------+
  28.  
  29. mysql> SELECT character_set_name FROM information_schema.`COLUMNS`
  30. -> WHERE table_schema = "myDatabase"
  31. -> AND table_name = "myTable"
  32. -> AND column_name = "myColumn";
  33. +--------------------+
  34. | character_set_name |
  35. +--------------------+
  36. | utf8mb4 |
  37. +--------------------+
  38.  
  39. #!/usr/bin/perl -w
  40. use strict;
  41. use warnings;
  42. use utf8;
  43. use Encode;
  44. use DBI;
  45. binmode STDOUT, ":utf8";
  46.  
  47. #Here I connect using the parameter mysql_enable_utf8 (create database handle):
  48. my $dbh = DBI->connect('DBI:mysql:database=myDatabase;host=localhost','aUser','aPassword',{mysql_enable_utf8 => 1});
  49.  
  50. #Prepare the statement (create statement handle):
  51. my $sth = $dbh->prepare('INSERT INTO `myTable` (`myColumn`) VALUES(?);');
  52.  
  53. #This doesn't work:
  54. $sth->execute('😜');
  55.  
  56. #This doesn't work either:
  57. $sth->execute(encode_utf8('😜'));
  58.  
  59. #end processing:
  60. $dbh->disconnect();
  61. exit(0);
  62.  
  63. 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