June 2017
Intermediate to advanced
536 pages
9h 49m
English
Using the PDO driver extension, we can connect to a MySQL database from PHP using the PDO class, as follows:
<?php$host = '127.0.0.1';$dbname = 'sakila';$username = 'root';$password = 'mL08e!Tq';$conn = new PDO( "mysql:host=$host;dbname=$dbname", $username, $password);
This simple multiline expression will look for MySQL on the 127.0.0.1 host and try to connect to its sakila database using the root username and mL08e!Tq password.