Bonjour,
J'ai un problème avec mon moteur de recherche dont je vous joins le code. Il me retourne des messages d'erreur au niveau de ma requête, je ne peux pas me connecter à ma base de données. Je travaille sous wampserver.
Si quelqu'un peut m'aider.
Merci beaucoup

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 
<?php
error_reporting(E_ALL ^ E_NOTICE);
$mot = $_POST['mot'];
?> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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.php" method="post">
Saisissez un ou plusieurs mots :
<input type="text" name="mot" size="20">
<input type="submit" value="Rechercher">
</form>
</body>
</html>
 
 
<?php
/******************************************************************
*	VARIABLES A MODIFIER
******************************************************************/
 
// NOMBRE DE RESULTATS PAR PAGE
$limit=2;
 
// NOM DE CE SCRIPT
$script_name="recherche.php";
 
// SERVEUR SQL
$sql_serveur="localhost";
 
// LOGIN SQL
$sql_user="root";
 
// MOT DE PASSE SQL
$sql_passwd="";
 
// BASE DE DONNEE
$sql_bdd="infos";
 
// 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);
 
$nombre_mots=count($mots);
 
$z=1;
$texte="Pages contenant <b>&quot;$mots[0]&quot;</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>&quot;$mots[$z]&quot;</b>";
	$z++;
	}
 
if($page==""){$page=0;}
$debut=$page*$limit;
 
// NOMBRE TOTAL D'ENREGISTREMENTS REPONDANT A LA REQUETE
$requete=mysql_select_db("$sql_bdd","select * from recherche where mots like $phrase limit $debut,$limit","$db_link");
$nb_total=mysql_result($requete,0,"count(*)");
 
$requete=mysql_select_db("$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&eacute;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>&nbsp;\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>)&nbsp;";}
		else {echo "<b>($j)</b>&nbsp;";}
		$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>