Can you please point out what I am doing wrong in following statement?
$db = new PDO('mysql:dbname=my-db-name','host=localhost', 'username', 'password', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';"));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
There is syntax error. I know it would be a silly question but i am kind of stuck here.
Thanks in advance.
you are doing wrong where you are giving you db:name and local host it should be like below
'mysql:dbname=my-db-name;host=localhost'
check that i added ;
in it, edit it and try it
new PDO('mysql:host=localhost;dbname=my-db-name', 'username', 'password' [...]
if i'm not wrong it should be something like
$db = new PDO('mysql:host=localhost;dbname=my-db-name', 'username', 'password', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';"));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);