Solution exercice 3:

<?php
try { $bdd= new PDO('@adresse;dbname=powerhost','U','PW'); }
catch (Exception $e)
{ die('Erreur de connexion à la BDD : '. $e->getmessage()); }
/*-----------------------------------------------------------*/
$d = date()-15;

$t="SELECT `ligne_adsl`.`num_adsl`
FROM `ligne_adsl`
WHERE `date_expir` <= $id";

$sql= $bdd->prepare($t);
try { $sql->execute(); }
catch (Exception $e) 
{  die("Erreur de requete./". $e->getmessage()); }
/*-------------------------------------------------*/
$ligne= $sql->fetchAll(\PDO::FETCH_ASSOC);
$nb= count($ligne);
if ( $nb > 0 )
{  $fp= fopen('sanctions.txt','w');
	for($i = 0 ; $i < $nb ;$i++)
{
$num=$ligne[$i]['num_adsl']; fputs($fp,$num.chr(10));
} fclose($fp); } else echo "Pas d'informations à afficher"; /*-------------------------------------------------*/ $sql->CloseCursor(); unset($bdd); ?>