I have a very simple PDO connection that I am trying to get connected to a db in xampp. On my laptop, xampp works and this code runs fine and connects to the db, but on my desktop I've installed xampp and tried the same code (same repo) and it spits out an error (could not find driver)
If anyone else has had this exact issue and has solved it, please help
Windows 11, xampp version 8.2.0
Much appreciated.
`<?php
$servername = "localhost";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$servername;dbname=oopphptest1", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}`
Ive spend the last couple of days researching this error and I have tried many of the solutions, uncommenting extentions in the php.ini file, uninstalling and reinstalling xampp and so on...
I also get this error, even when xampp isn't running (the usual error is: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it), but even then it just spits out could not find driver whether xampp is running or not.
After searching in phpinfo(); under PDO, values are set and it is enabled...