Warning: PDO::__construct() expects parameter 4 to be array, string given

burnedfaceless
burnedfaceless used Ask the Experts™
on
?php
  $db = new PDO('mysql: host=host.com',
    'dbname=name',
    'user',
    'pass');
?>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
Commented:
Try this version:
<?php
  $db = new PDO('mysql:dbname=name;host=host.com',
    'user',
    'pass');
?>
From http://php.net/manual/en/pdo.construct.php
Most Valuable Expert 2011
Top Expert 2016
Commented:
PDO, compared to MySQL and MySQLi:
http://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

Abbreviated version, for those who are already conversant in the PHP database extensions:
http://iconoun.com/mysql_mysqli_pdo_function_map.php

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial