Hi, I apologize in advance for my English.
I bought the fifth edition of the Italian version of the book by Kevin Yank “Build Your Own Website Using PHP And MySQL Database”.
I followed the guide in the appendix to manually install in Linux, I use Ubuntu 12.10, MySQL and PHP.
Understood to 4 explains how to connect to a database, created in advance, via PDO.
Shows the result of the following script:
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=ijdb', 'ijdbuser', 'mypassword');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf-8"');
}
catch (PDOException $e)
{
$output = 'Impossibile connettersi al server di database: ' .
$e->getMessage();
include 'output.html.php';
exit();
}
$output = 'Connessione al database stabilita.';
include 'output.html.php';
I get the following error:
Impossibile connettersi al server di database: could not find driver
That proves that you’re able to connect to the mysql server ok.
To get PDO going:
Run this script php <?php phpinfo(); ?>
With the output from the script in step 1 look for the line “Loaded Configuration File”
Open up the file called php.ini that is located at the location given in “Loaded Configuration File”
Find a line that reads
> extension=php_pdo_mysql.dll
there is probably a ; at the start of that line, remove the ; from the start of that line and save the file.
Restart the server (whenever you make configuration changes to a server as a rule of thumb the server will normally need to be restarted for the changes to take affect).