Reputation: 174
When I use the function mysql_set_charset('utf8');
I have this error :
Warning: mysql_set_charset() expects parameter 2 to be resource, object given in D:\wamp\www\plateforme\includes\db.php on line 4
This is the code :
<?php
$db = new PDO('mysql:host=localhost;dbname=plateforme', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
mysql_set_charset('utf8',$db);
?>
Upvotes: 1
Views: 1142
Reputation: 68536
You are mixing mysql_*
and PDO
, Set the character encoding like this to your existing connection object and remove that mysql_set_charset('utf8',$db);
..
$db = new PDO('mysql:host=localhost;dbname=plateforme;charset=utf8', 'root', '');
^^^^^^^^^^^^^ //<--- This.
Upvotes: 6