title: Can't insert Symbols like '€' in MySQL using PHP/PDO
body: <p>I am trying to insert some data in my database table but I am getting this exception, when I am trying to save the € Euro symbol in the currency column: </p>
  
  <pre><code>PDOException: SQLSTATE[HY000]: General error: 1366 
  Incorrect string value:  '\x80' for column 'currency' at row 1
  </code></pre>
  
  <p>If I don't use any symbols it is working fine. No exception is thrown and the data is written correctly in the database table.</p>
  
  <p>That is the technology stack I am using:</p>
  
  <ul>
  <li>PHP  5.6.16</li>
  <li>MySQL 5.7</li>
  <li>Apache 2.4</li>
  <li>PDO (instead of mysqli)</li>
  </ul>
  
  <p>I have tried to google a solution, but nothing worked for me:</p>
  
  <ul>
  <li>I tried to change the character set of my database, tables and columns to UTF8mb4</li>
  <li>I made configuration changes to character sets in my php.ini</li>
  <li>I tried it with mysqli and maysql instead of PDO</li>
  <li>I have wrote "charset=utf8mb4" in the connection String of the PDO object</li>
  </ul>
  
  <p>But nothing was helpful...</p>
  
  <p>This is the create script of my table, I am using at the moment:</p>
  
  <pre><code>CREATE TABLE `cars` (
  `car_id` int(11) NOT NULL AUTO_INCREMENT,
  `brand` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `car_trim` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model_year` int(11) DEFAULT NULL,
  `car_condition` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `car_type` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, &lt;-- Where the € should be
  PRIMARY KEY (`xy`)
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4   
  COLLATE=utf8mb4_unicode_ci;
  </code></pre>
  
  <p>My PDO connection looks like this:</p>
  
  <pre><code>    if(!isset(self::$connection)) {
        try {
          self::$connection = new PDO('mysql:host='.self::$config['host'].
                                   ';dbname='.self::$config['dbname'].
                                   ';port='.self::$config['port'].
                                   ';charset='.self::$config['charset'], //utf8mb4
                                   self::$config['username'], 
                                   self::$config['password']
                                 );
          self::$connection-&gt;setAttribute( PDO::ATTR_ERRMODE,  
                                           PDO::ERRMODE_EXCEPTION );
        } catch (PDOException $e) {
          self::$logger-&gt;LogError('Connection.php: ' . $e-&gt;getMessage());
          echo $e-&gt;getMessage();
          self::$connection-&gt;rollBack();
          $this-&gt;closeConnection();
    }
  }
  </code></pre>
  
  <p>The PHP code with the insert statement:</p>
  
  <pre><code>$db = new Db();
  
  $car = new Car($_POST['carBrand'], $_POST['carModel'], $_POST['carTrim'],    
  $_POST['carModelYear'], $_POST['carCondition'],
  $_POST['carType'], $_POST['carFuelType'], $_POST['carTransmission'],  
  $_POST['carEngine'], $_POST['carCylinder'],
  $_POST['carMileage'], $_POST['carExteriorColor'],  
  $_POST['carInteriorColor'], $_POST['carLocation'], $_POST['carVin'],
  $_POST['carDriveTrain'], $_POST['carStock'], $_POST['carPrice'], 
  $_POST['carPriceDetails'], $_POST['carCurrency'],
  $_POST['carTax'], $_POST['carTaxDetails'], $_POST['carDescr'], 
  $_POST['carBodyDescr'], $_POST['carDriveTrainDescr'],
  $_POST['carExteriorDescr'], $_POST['carElectronicsDescr'],  
  $_POST['carSaftyFeaturesDescr'], $_POST['carSpecialFeaturesDescr'],
  null, null, null, null, null, null, null, null, null, null, 'Edi', 'Edi', 
  (empty($_POST['carOnline'])) ? 'off' : 'on');
  
  $car_insertStm = 'INSERT INTO cardealer.cars ( ' . 
  'brand, model,car_trim,model_year,car_condition,car_type, fuel_type, transmission, ' .
  'car_engine, cylinder, mileage, exterior_color, interior_color, location, vin, drive_train, ' . 
  'stock, price, price_descr, currency, tax, tax_descr, car_descr_long, body_descr, ' . 
  drive_train_descr, exterior_descr, electronics_descr, safty_features_descr, special_features_descr, car_pic_1, car_pic_2, car_pic_3, ' . 
  'car_pic_4, car_pic_5, car_pic_6, car_pic_7, car_pic_8, car_pic_9, car_pic_10, create_user, ' . 
  'change_user, car_online ) ' .
  'VALUES ( :brand, :model, :car_trim, :model_year, :car_condition, :car_type,  :fuel_type, :transmission, :car_engine, :cylinder, ' .
  ':mileage, :exterior_color, :interior_color, :location, :vin, :drive_train, 
  :stock, :price, :price_descr, :currency, :tax, :tax_descr, ' .
  ':car_descr_long, :body_descr, :drive_train_descr, :exterior_descr, 
  :electronics_descr, :safty_features_descr, :special_features_descr, ' .
  ':car_pic_1, :car_pic_2, :car_pic_3, :car_pic_4, :car_pic_5, :car_pic_6, 
  :car_pic_7, :car_pic_8, :car_pic_9, :car_pic_10, :create_user, ' .
  ':change_user, :online ) ';
  
  $pStatement = $db-&gt;getConnection()-&gt;prepare($car_insertStm);
  
  $pStatement-&gt;bindParam(':brand', $_POST['carBrand'], PDO::PARAM_STR);
  $pStatement-&gt;bindParam(':model', $_POST['carModel'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':car_trim', $_POST['carTrim'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':model_year',            
                          $_POST['carModelYear'],PDO::PARAM_INT);         
  $pStatement-&gt;bindParam(':car_condition', 
                          $_POST['carCondition'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':car_type', $_POST['carType'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':fuel_type', $_POST['carFuelType'], PDO::PARAM_STR);        
  $pStatement-&gt;bindParam(':transmission', 
                          $_POST['carTransmission'], PDO::PARAM_STR);
  $pStatement-&gt;bindParam(':car_engine', $_POST['carEngine'], PDO::PARAM_STR);             
  $pStatement-&gt;bindParam(':cylinder', $_POST['carCylinder'], PDO::PARAM_STR);       
  $pStatement-&gt;bindParam(':mileage', $_POST['carMileage'],PDO::PARAM_INT);        
  $pStatement-&gt;bindParam(':exterior_color', 
                          $_POST['carExteriorColor'], PDO::PARAM_STR); 
  $pStatement-&gt;bindParam(':interior_color', 
                          $_POST['carInteriorColor'], PDO::PARAM_STR);     
  $pStatement-&gt;bindParam(':location', $_POST['carLocation'], PDO::PARAM_STR);     
  $pStatement-&gt;bindParam(':vin', $_POST['carVin'], PDO::PARAM_STR );          
  $pStatement-&gt;bindParam(':drive_train', 
                          $_POST['carDriveTrain'], PDO::PARAM_STR);
  $pStatement-&gt;bindParam(':stock', $_POST['carStock'], PDO::PARAM_STR);           
  $pStatement-&gt;bindParam(':price', $_POST['carPrice'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':price_descr', 
                         $_POST['carPriceDetails'], PDO::PARAM_STR);    
  $pStatement-&gt;bindParam(':currency', $_POST['carCurrency'], PDO::PARAM_STR); // Parameter binding for the currency --&gt; €     
  $pStatement-&gt;bindParam(':tax', $_POST['carTax'],PDO::PARAM_INT);             
  $pStatement-&gt;bindParam(':tax_descr', 
                         $_POST['carTaxDetails'], PDO::PARAM_STR);    
  $pStatement-&gt;bindParam(':car_descr_long', 
                         $_POST['carDescr'], PDO::PARAM_STR);         
  $pStatement-&gt;bindParam(':body_descr', 
                         $_POST['carBodyDescr'], PDO::PARAM_STR);
  $pStatement-&gt;bindParam(':drive_train_descr', 
                         $_POST['carDriveTrainDescr'], PDO::PARAM_STR);
  $pStatement-&gt;bindParam(':exterior_descr', 
                         $_POST['carExteriorDescr'], PDO::PARAM_STR); 
  $pStatement-&gt;bindParam(':electronics_descr', 
                         $_POST['carElectronicsDescr'], PDO::PARAM_STR);    
  $pStatement-&gt;bindParam(':safty_features_descr',   
                         $_POST['carSaftyFeaturesDescr'], PDO::PARAM_STR);  
  $pStatement-&gt;bindParam(':special_features_descr',  
                         $_POST['carSpecialFeaturesDescr'], PDO::PARAM_STR); 
  $pStatement-&gt;bindValue(':car_pic_1', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_2', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_3', null, PDO::PARAM_LOB);
  $pStatement-&gt;bindValue(':car_pic_4', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_5', null, PDO::PARAM_LOB);       
  $pStatement-&gt;bindValue(':car_pic_6', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_7', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_8', null, PDO::PARAM_LOB);              
  $pStatement-&gt;bindValue(':car_pic_9', null, PDO::PARAM_LOB);         
  $pStatement-&gt;bindValue(':car_pic_10', null, PDO::PARAM_LOB);            
  $pStatement-&gt;bindValue(':create_user', "Edi", PDO::PARAM_STR);      
  $pStatement-&gt;bindValue(':change_user', "Edi", PDO::PARAM_STR);  
  $pStatement-&gt;bindValue(':online', 
                         (empty($_POST['carOnline'])) ? "off" : "on", 
                         PDO::PARAM_STR);
  
  $result = $pStatement-&gt;execute();
  </code></pre>
  
  <p>Would be very nice if someone could help me out of that mes.
  Every help is highly appriciated.</p>
  
  <p>Thanks in advance.</p>