Bonjour,
alors pour commencer je suis une quiche en php mais quand je dis que mon code est bon, c'est parce qu'il fonctionne sans aucun probleme avec easyphp 1.8 et que plus rien ne fonctionne sous easyphp 5.3.1 donc je suppose qu'il est bon ou au moins fonctionnel.
Sinon j'ai pris un script tout simple de moteur de recherche sur phpscript et je l'ai testé sans succès, voici le code :
<html>
<head>
<title>Résultat de la recherche</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body text="#FFFFFF" bgcolor="#000000" link="#9999FF" vlink="#6699FF" alink="#FFFF00">
<font face="Verdana" size=2>
<form action="recherche.php3" method="post">
Saisissez un ou plusieurs mots :
<input type="text" name="mot" size="20">
<input type="submit" value="Rechercher">
</form>
<?
/******************************************************************
* VARIABLES A MODIFIER
******************************************************************/
// NOMBRE DE RESULTATS PAR PAGE
$limit=2;
// NOM DE CE SCRIPT
$script_name="recherche.php3";
// SERVEUR SQL
$sql_serveur="localhost";
// LOGIN SQL
$sql_user="root";
// MOT DE PASSE SQL
$sql_passwd="";
// BASE DE DONNEE
$sql_bdd="bddsite";
// RECHERCHE AVEC TOUS LES MOTS : METTEZ "and"
// RECHERCHER LES PAGES QUI CONTIENNENT AU MOINS UN MOT : METTEZ "or"
$et_ou="or";
/******************************************************************
* PROGRAMME PRINCIPAL
******************************************************************/
$db_link = mysql_connect("$sql_serveur","$sql_user","$sql_passwd");
$mot=strtolower($mot);
$mots=split(" ",$mot);
$nombre_mots=count($mots);
$z=1;
$texte="Pages contenant <b>"$mots[0]"</b>";
$phrase="'%$mots[0]%'";
while($z<$nombre_mots)
{
$phrase.=" ".$et_ou." mots like '%$mots[$z]%'";
$texte.=" ";
if($et_ou=="and"){$texte.="et";}else{$texte.="ou";}
$texte.=" <b>"$mots[$z]"</b>";
$z++;
}
if($debut==""){$debut=0;}
$debut=$page*$limit;
// NOMBRE TOTAL D'ENREGISTREMENTS REPONDANT A LA REQUETE
$requete=mysql_db_query("$sql_bdd","select count(*) from recherche where mots like $phrase order by id",$db_link);
$nb_total=mysql_result($requete,0,"count(*)");
$requete=mysql_db_query("$sql_bdd","select * from recherche where mots like $phrase limit $debut,$limit",$db_link);
$num=mysql_num_rows($requete);
// DEFINITION DU MESSAGE A AFFICHER
if ($num==0) {echo "Désolé, aucune page de ce site ne contient <b>$mot</b>...";}
else if ($mot=="") {echo "Veuillez saisir un ou plusieurs mot-clés avant de cliquer sur 'OK' !";}
else if (strlen($mot)<2) {echo "Veuillez saisir au moins 2 caractères.";}
// AFFICHAGE DES RESULTATS
else {
echo "<b>$nb_total</b> réponse";
if ($nb_total>1) {echo "s";}
echo "<br>$texte";
$i=0;
while($i<$num)
{
$url=mysql_result($requete,$i,"url");
$description=mysql_result($requete,$i,"description");
$titre=mysql_result($requete,$i,"titre");
echo "<br><br><a href=\"$url\"><b>$titre</b></a><br>$description<br><font size=1>$url</font>\n";
$i++;
}
echo "<br><br>";
// AFFICHAGE DU LIEN PRECEDENT SI BESOIN EST
// (LA PREMIERE PAGES EST 0)
if ($page>0)
{
$precedent=$page-1;
print "<a href=\"$script_name?page=$precedent&mot=$mot\">PRECEDENT</a> \n";
}
// AFFICHAGE DES NUMEROS DE PAGE
$i=0;$j=1;
if($nb_total>$limit)
{
while($i<($nb_total/$limit))
{
if($i!=$page){echo "(<a href=\"$script_name?page=$i&mot=$mot\">$j</a>) ";}
else {echo "<b>($j)</b> ";}
$i++;$j++;
}
}
// AFFICHAGE DU LIEN SUIVANT SI BESOIN EST
if($debut+$limit<$nb_total)
{
$suivant=$page+1;
echo "<a href=\"$script_name?page=$suivant&mot=$mot\">SUIVANT</a>";
}
}
// DECONNEXION DE LA BASE DE DONNEE
mysql_close($db_link);
?>
</font>
</body>
</html>
Ensuite je tourne sous easyphp 5.3.1 a savoir mysql 5.1.4.3 et php 5.3.1.
Quand je lance la page en web local voici ce que j'ai :
"$mots[0]""; $phrase="'%$mots[0]%'"; while($z<$nombre_mots) { $phrase.=" ".$et_ou." mots like '%$mots[$z]%'"; $texte.=" "; if($et_ou=="and"){$texte.="et";}else{$texte.="ou";} $texte.=" "$mots[$z]""; $z++; } if($debut==""){$debut=0;} $debut=$page*$limit; // NOMBRE TOTAL D'ENREGISTREMENTS REPONDANT A LA REQUETE $requete=mysql_db_query("$sql_bdd","select count(*) from recherche where mots like $phrase order by id",$db_link); $nb_total=mysql_result($requete,0,"count(*)"); $requete=mysql_db_query("$sql_bdd","select * from recherche where mots like $phrase limit $debut,$limit",$db_link); $num=mysql_num_rows($requete); // DEFINITION DU MESSAGE A AFFICHER if ($num==0) {echo "Désolé, aucune page de ce site ne contient $mot...";} else if ($mot=="") {echo "Veuillez saisir un ou plusieurs mot-clés avant de cliquer sur 'OK' !";} else if (strlen($mot)<2) {echo "Veuillez saisir au moins 2 caractères.";} // AFFICHAGE DES RESULTATS else { echo "$nb_total réponse"; if ($nb_total>1) {echo "s";} echo "
$texte"; $i=0; while($i<$num) { $url=mysql_result($requete,$i,"url"); $description=mysql_result($requete,$i,"description"); $titre=mysql_result($requete,$i,"titre"); echo "
$titre
$description
$url\n"; $i++; } echo "
"; // AFFICHAGE DU LIEN PRECEDENT SI BESOIN EST // (LA PREMIERE PAGES EST 0) if ($page>0) { $precedent=$page-1; print "PRECEDENT \n"; } // AFFICHAGE DES NUMEROS DE PAGE $i=0;$j=1; if($nb_total>$limit) { while($i<($nb_total/$limit)) { if($i!=$page){echo "($j) ";} else {echo "($j) ";} $i++;$j++; } } // AFFICHAGE DU LIEN SUIVANT SI BESOIN EST if($debut+$limit<$nb_total) { $suivant=$page+1; echo "SUIVANT"; } } // DECONNEXION DE LA BASE DE DONNEE mysql_close($db_link); ?>
Merci d'avance pour vos réponses !