Answer the question
In order to leave comments, you need to log in
How to connect to Open Server DB via PHP?
When I go to PHP Adminer, I log in with the data below without any problems. The script itself for some reason does not want to connect to the Open Server database. How to decide?
<?php
$host = 'localhost';
$db = 'u14215_default';
$user = 'root';
$pass = 'admin';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_PERSISTENT => true,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question