I am having problems connecting to my database on the web host that I have, I use the following:
$dsn = 'mysql:host=mysql1.hosting.digiweb.ie;dbname=mydbname';
$user = 'myusername';
$password = 'mypassword';
According to the website: Hostname mysql1.hosting.digiweb.ie (ip address)
as the title says that I get a I canβt find the driver error, I enter the host incorrectly, I tried to log in as above, as well as the ip address - Thanks!
Edit:
Here is all my code
<?php
$dsn = 'mysql:host=localhost;dbname=';
$user = '';
$password = '';
try {
$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
echo 'Database connection failed - ';
echo $e->getMessage();
exit;
}
echo 'works';
?>
source
share