Trying to connect to a remote mysql server with php inserted into html.
I'm getting an error:
could not find driver with the below code.
The mysql example in the link does not return anything.
What I want is to extract and save info plus edit, create tables through http. How can I do that?
MySql version: 5.7.22-0ubuntu18.04.1
Php version: PHP Version 7.2.3-1ubuntu1
Source: php pdo code
<?php
//Database Credentials
$host = 'localhost';
$database = 'dbName';
$username = 'userName';
$password = 'userPassword';
try {
$DBH = new PDO("mysql:host=$host;dbname=$database", $username, $password); }
catch(PDOException $e) {
echo "did catch that! ";
echo $e->getMessage(); }
echo " #it works";
?>
Edit note: Got it working after following Thomas Deutschländer advice. Server is local and php is running on server, are going to view results/return from php in web page from local and remote net.
Some info:
Gained (viewed from php -m) after sudo apt-get install php-mysql:
mysqli
mysqlnd
pdo_mysql
(viewed from dpkg --get-selections | grep php)
php-mysql
php7.2-mysql
(viewed from dpkg --get-selections | grep mysql)
php-mysql
php7.2-mysql
Had previously:
PDO - viewed from php -m