0

So I am constantly getting this error even after modifying my table's character set using another solution found here on SO that worked fine for when I used node.js for my twitter bot. Does PDO override my changes, and if so, how can I fix that?

this is the SO post i am referencing: Incorrect string value: '\xF0\x9F\x8E\xB6\xF0\x9F...' MySQL

and tihs is how I am doing my pdo statement.

$sql = "INSERT INTO tweet (tweet, posted, Category_idCategory, Username) 
            VALUES (?, ?, ?, ?);";

            $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

            $notOther = false;


            foreach (self::$politics as $result) {
                if (strpos(strtolower($tweet), strtolower($result)) !== false) {
                    $notOther = true;

                    $execute = $dbh->prepare($sql);
                    $execute->execute(array($tweet, $date, 2, $username));

                    break;
                }
            }
Community
  • 1
  • 1
SomeStudent
  • 2,856
  • 1
  • 22
  • 36
  • Your PDO connection is in utf8? – chris85 Apr 18 '17 at 00:22
  • of that I am unsure, I have not used pdo much, my understanding was that pdo just allows you to interact with the DB and that it is the DB that decides what charset it uses. How can I change the pdo to not be utf8? – SomeStudent Apr 18 '17 at 00:23
  • 1
    You want it to be utf8. http://stackoverflow.com/questions/4361459/php-pdo-charset-set-names – chris85 Apr 18 '17 at 00:24
  • I am fairly positive the table was initially utf8 per the schema CREATE SCHEMA IF NOT EXISTS `UserData` DEFAULT CHARACTER SET utf8 ; – SomeStudent Apr 18 '17 at 00:28
  • @chris85 the link u posted did the trick, feel free to give it as an answer and I will mark it as correct :) – SomeStudent Apr 18 '17 at 00:31
  • We should just mark is as a duplicate. If another user comes here with a similiar search they will be able to find that thread. That thread also has multiple answers so could answer a few different scenarios. – chris85 Apr 18 '17 at 00:43

0 Answers0