Je me permet de poster mon souci après fouiner sur le forum. J'ai trouver des topics similaires au miens mais comme je suis vraiment débutant en PHP, je demande votre aide.
Voilà en fait j'ai hérité d'un site Intranet comportant de nombreux scripts fait en PHP 5.3.28 et comme je dois migrer tout le site vers un CMS plus recent alors je suis obligé de passer à PHP 5.6 minimum. Alors il se pose un problème de compatibilité (MySql et MySqli) qui m'envoie des erreurs:
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp64\www\afristat\components\com_jumi\files\afristat_scripts\absence_liki.php on line 7
Aucune base n'a �t� s�lectionn�eAucune base n'a �t� s�lectionn�e
ou
Notice: Undefined variable: affichage_php in C:\wamp64\www\afristat\components\com_jumi\files\afristat_scripts\absence_liki.php on line 116
ou encore:
Notice: Undefined variable: affichage_php1 in C:\wamp64\www\afristat\components\com_jumi\files\afristat_scripts\manifestations_afristat_liste.php on line 21
Voici le code du script qui envoie ces erreurs:
Code : Tout sélectionner
<?php
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date_depart_saf,date_retour_saf,pays,date1,date2 FROM afristat_absences WHERE actif='Y' AND ";
$sql .= "((validation <'9' AND date_depart_saf<='" . $aujourdhui . "' AND date_retour_saf>='" . $aujourdhui . "') OR ";
$sql .= " (type='2' AND date1<='" . $aujourdhui . "' AND date2>='" . $aujourdhui . "')) ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow=mysql_num_rows($ma_requete);
$affichage_php .= "<p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences du jour</u></b> : les dates de départ et de retour sont celles du billet d'avion ou de la demande d'absence</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Date de départ</th>
<th scope='col' class='rounded-top-right'>Date de retour</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://afristat02/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
if (($mon_resultat["pays"] != 'n/a')) {
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from afristat_liste_pays where code3='$pays'");
$res = @mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
}else {
$pays = "En congés";
$affichage_php .= "<td>".$pays."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
$affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
}
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
$aujourdhui=date("Y-n-j");
$sql = "SELECT DISTINCT nom,date1,date2,date_depart_saf,date_retour_saf,pays FROM afristat_absences WHERE actif='Y' AND ";
$sql .= "((validation = '1' AND type='1') OR (validation = '0' AND type='2')) AND date1>'" . $aujourdhui . "' OR date_depart_saf>'" . $aujourdhui . "' ORDER BY nom";
$ma_requete = mysql_query($sql);
echo mysql_error();
if ($ma_requete) {
$nbrow=mysql_num_rows($ma_requete);
$affichage_php .= "<p></p><p style='padding-left:8pt; font:arial; color:blue'><b><u>Liste des absences à venir</u></b> : les demandes ci-dessous ont été autorisées par la Direction Générale</p><table id='rounded-corner' summary='Absences de la période'>
<thead>
<tr>
<th scope='col' class='rounded-top-left'>Nom de l'agent</th>
<th scope='col' class='rounded-pays'>Pays</th>
<th scope='col' class='rounded-depart'>Départ probable</th>
<th scope='col' class='rounded-top-right'>Retour probable</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='3' class='rounded-foot-left'><em><a href='http://afristat02/intranet/index.php?option=com_content&view=article&id=93'>Pour plus d'information, merci de consulter la page des absences</a></em></td>
<td class='rounded-foot-right'> </td>
</tr>
</tfoot>
<tbody>";
if( $nbrow > 0) {
$i=1;
while ($mon_resultat = mysql_fetch_array($ma_requete)) {
//$affichage_php .= "<b>" . $mon_resultat["nom"] . "</b> (><i>" . date("d-m-Y",strtotime($mon_resultat["date2"])) . "</i>)";
//$affichage_php .= ($i++<$nbrow?", ":"");
$pays = $mon_resultat["pays"];
$req = mysql_query("select pays from afristat_liste_pays where code3='$pays'");
//echo var_dump($pays)." ".var_dump($req)."<br />";
$res = mysql_fetch_array($req);
if (isset($res["pays"])) $pays = $res["pays"];
else $pays = "En congés";
$affichage_php .= "<tr>";
$affichage_php .= "<td>".$mon_resultat["nom"]."</td>";
$affichage_php .= "<td>".$pays."</td>";
if ($mon_resultat["date_depart_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_depart_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date1"]))."</td>";
if ($mon_resultat["date_retour_saf"] != '0000-00-00') $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date_retour_saf"]))."</td>";
else $affichage_php .= "<td>".date("d / m / Y",strtotime($mon_resultat["date2"]))."</td>";
$affichage_php .= "</tr>";
}
}
else {
//$affichage_php .= "<div class='texte' style='padding-left:8pt; font:arial; color:blue'>>> <u>Absence(s) du jour:</u> ";
$affichage_php .="<i>aucune...</i>";
//$affichage_php .= "</div><br>";
}
$affichage_php .= "</tbody></table>";
}
echo $affichage_php;
?>