Solution exercice 1:

<?php
try { $bdd = new PDO('@adresse','U','PW'); }
catch (Exception $e) {	die('Erreur de connexion au serveur / '. $e->getmessage()); } 

$sql= $bdd->prepare("create database if not exists `powerhost`");

try { $sql->execute(); }
catch (Exception $e)
{ die('erreur de création de la BDD / '. $e->getmessage()); }

try { $bdd= new PDO('@adresse;dbname=powerhost','U','PW'); }
catch (Exception $e)
{ die('Erreur de connexion à la BDD : '. $e->getmessage()); }
/*-----------------------------------------------------------*/
$t[]="CREATE TABLE IF NOT EXISTS `admin` (
  `login` varchar(6) PRIMARY KEY,
  `mdp` varchar(4))";

$t[]="CREATE TABLE IF NOT EXISTS `carte_recharge` (
  `code` varchar(6) PRIMARY KEY,
  `montant` int(4),
  `durée` int(3),
  `date_recharg` date,
  `num_adsl` varchar(6),
  `login` varchar(6),
   KEY `num_adsl` (`num_adsl`),
   KEY `login` (`login`))";

$t[]="CREATE TABLE IF NOT EXISTS `ligne_adsl` (
  `num_adsl` varchar(6) PRIMARY KEY,
  `debit` varchar(6),
  `date_expir` date)";

$t[]="CREATE TABLE IF NOT EXISTS `wilaya` (
  `codew` varchar(2) PRIMARY KEY,
  `wilaya` varchar(10),
  `login` varchar(6),
   KEY `login` (`login`))";

for($i=0; $i < count($t);$i++)
{	$sql= $bdd->prepare($t[$i]);
	try { $sql->execute(); }
	catch (Exception $e) 
   {  die("Erreur de creation de la table $t[$i]./". $e->getmessage()); }
}
/*-------------------------------------------------*/
$t[]="INSERT INTO `admin` (`login`, `mdp`) VALUES
('admin1', 'mdp1'),
('admin2', 'mdp2'),
('admin3', 'mdp3')";

$t[]="INSERT INTO `carte_recharge` (`code`, `montant`, `durée`, `date_recharg`, `num_adsl`, `login`) VALUES
('111', 500,  7, '2019-01-07', '111111', 'admin1'),
('222',1000, 15, '2019-01-09', '222222', 'admin2'),
('333', 500,  7, '0000-00-00', '      ', 'admin1'),
('444',1000, 15, '0000-00-00', '      ', 'admin2'),
('555', 500,  7, '2019-01-19', '222222', 'admin2'),
('666',2000, 30, '2019-01-28', '333333', 'admin3'),
('777', 500,  7, '0000-00-00', '      ', 'admin3')";

$t[]="INSERT INTO `ligne_adsl` (`num_adsl`, `debit`, `date_expir`) VALUES
('111111', '1 mbps', '2019-01-07'),
('222222', '2 mbps', '2019-01-09'),
('333333', '20mbps', '2019-01-19')";

$t[]="INSERT INTO `wilaya` (`codew`, `wilaya`, `login`) VALUES
('01', 'wilaya01', 'admin1'),
('02', 'wilaya02', 'admin2'),
('03', 'wilaya03', 'admin3')";

for($i=0; $i < count($t);$i++)
{	$sql= $bdd->prepare($t[$i]);
	try { $sql->execute(); }
	catch (Exception $e) 
   { die("Erreur d'insertion dans la table $t[$i]./". $e->getmessage()); }
}
/*-------------------------------------------------*/
$sql->CloseCursor();
unset($bdd);
?>