I tried to connect to MySQL database using PDO and mysqli using msqli : PHP: <?phpnamespace ImSQLPlugin;use pocketmine\plugin\PluginBase;class Main extends PluginBase{ public function onEnable() { $host = "localhost"; $user = "root"; $password = ""; $database = "PMdata"; $port = 3306; $this->database = new \mysqli($host, $user, $password, $database, $port); if($this->database->connect_error) { $this->getServer()->shutdown(); } $this->databse->query("CREATE TABLE IF NOT EXISTS players (name VARCHAR(16) PRIMARY KEY, id INT)"); } public function onDisable() { $this->databse->close(); }} if I use mysqli I get that error in console : [Server thread/CRITICAL]: Error: "Call to undefined function ImSQLPlugin\mysqli_connect()" (EXCEPTION) in "ImSQLPlugin/src/ImSQLPlugin/Main" using PDO : PHP: <?phpnamespace ImSQLPlugin;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as Color;class Main extends PluginBase{ public function onEnable() { $this->getLogger()->info(Color::GREEN . "ImSQLPlugin has Enabled"); /* start sql connection */ $dsn = 'mysql:host=localhost;dbname=PMdata'; $user = 'root'; $pass = ''; try { $db = new \PDO($dsn, $user, $pass); $this->getLogger()->info(Color::GREEN . "you are connected"); }catch (\PDOException $e) { $this->getLogger()->info(Color::RED . "error :" . $e->getMessage()); } /* endc sql connection */ } public function onDisable() { $this->getLogger()->info(Color::RED . "ImSQLPlugin has Disabled"); }} if I use PDO I get that error in console : [Server thread/CRITICAL]: Error: "Class 'PDO' not found" (EXCEPTION) in "ImSQLPlugin/src/ImSQLPlugin/Main" how can I fix that please ?
Clearly, the code doesn't match the error. I cannot see any mysqli_connect(). Install the PDO extension depending on your host specifications.
What OS are you in? Also check the php.ini of your PHP binaries. There may be an ;extension=mysqli line. Try removing the semicolon.