LeonLatex Posted March 8, 2023 Share Posted March 8, 2023 I paste my script here. It won't connect, and I can't find the reason. Can you see where the bug in the script is? I appreciate your help if you can see it. <?php try { $pdo = new PDO('mysql:host=127.0.0.1;dbname=mydb; charset=utf8', 'myuser', 'mypass'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $output = ('Databasetilkobling er opprettet.'; } catch (PDOException $e) { $output = 'Får ikke kontakt med server, eller kan ikke koble til databasen:' . $e; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/315987-mysql-pdo-problem/ Share on other sites More sharing options...
Barand Posted March 8, 2023 Share Posted March 8, 2023 try $pdo = new PDO('mysql:host=127.0.0.1;dbname=mydb; charset=utf8', 'myuser', 'mypass'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); In other words, remove your try/catch stuff - you are smothering the error reporting Quote Link to comment https://forums.phpfreaks.com/topic/315987-mysql-pdo-problem/#findComment-1606352 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.