Problems with mysql

0

So, guys, I did a shopping cart in php using wampserver. I created the DB in mysql and created two BD ones with the name "mxmaster" and another with the name "shop". I made the connections all right in php, creating cart, products, home, through MVC (Object Oriented). But when I put it to pull through the index, to see the BD it gives these errors:

  

"Fatal error: Uncaught exception 'PDOException' with message   'SQLSTATE [HY000] [1049] Unknown database' shop '' in   C: \ wamp64 \ www \ shopping \ index.php on line 12 "

But the DBs are created and populated. This is the line of code 12 which he speaks and I have already changed the name to shop and to mxmaster and continue.

$pdo = new \PDO("mysql:host=localhost;dbname=shop", "root", "");

Anyone know how to solve this problem?

    
asked by anonymous 22.11.2017 / 01:10

1 answer

0

Try to pass the username and password this way:

$pdo = new \PDO("mysql:host=localhost;dbname=shop", "root", "");

without the part of the username and passwd that is on the same line in the image codes.

    
22.11.2017 / 01:42