svp si qlq 1 a une idee , le projet fonctionne sauf , quand je veux rechercher il m affiche l erreur suivante : Undefined variable: search in C:\wamp\www\48720-1256465-g-sav-le-gestionnaire-des-maintenances-informatiques\G-Sav_free\recherche.php on line 19

voila :
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
<?php
include("includes/header.php");
 
//Get variables from includes/config.php to connect to mysql server
require 'includes/config.php';
 
// connect to the mysql database server.
mysql_connect ($hostname, $user, $pass);
//select the database
mysql_select_db($dbase) or die('Cannot select database');
 
//search variable = data in search box or url
if(isset($_GET['search']))
{
$search = $_GET['search'];
}
 
//trim whitespace from variable
//Ligne 19
$search = trim($search);
$search = preg_replace('/\s+/', ' ', $search);
 
//seperate multiple keywords into array space delimited
$keywords = explode(" ", $search);
 
//Clean empty arrays so they don't get every row as result
$keywords = array_diff($keywords, array(""));
 
//Set the MySQL query
if ($search == NULL or $search == '%'){
} else {
for ($i=0; $i<count($keywords); $i++) {
$query = "SELECT * FROM fiche " .
"WHERE nom LIKE '%".$keywords[$i]."%'".
" OR id LIKE '%".$keywords[$i]."%'" .
" OR date LIKE '%".$keywords[$i]."%'" .
" OR prenom LIKE '%".$keywords[$i]."%'" .
" ORDER BY nom";
}
 
//Store the results in a variable or die if query fails
$result = mysql_query($query) or die(mysql_error());
}
if ($search == NULL or $search == '%'){
} else {
//Count the rows retrived
$count = mysql_num_rows($result);
}
 
echo "<body onLoad=\"self.focus();document.searchform.search.focus()\">";
echo "<center><table border=\"0\" class=\"table\">";
echo "   <tr>";
echo "      <td class=\"titre\">RECHERCHER</td>";
echo "   </tr>";
echo "</table></center>";
echo "<table border=\"0\">";
echo "   <tr>";
echo "      <td><font color=\"#000000\">Vous pouvez effectuer une recherche par N�, Nom, Pr�nom, Date ou tout autres mots cl�s pr�sent dans une fiche !</font></td>";
echo "   </tr>";
echo "</table>";
echo "<br /><center><form name=\"searchform\" method=\"GET\" action=\"recherche.php\">";
echo "<input type=\"text\" name=\"search\" size=\"20\" TABINDEX=\"1\" />";
echo " <input type=\"submit\" value=\"Rechercher\" />";
echo "</form>";
//If search variable is null do nothing, else print it.
if ($search == NULL) {
} else {
echo "Resultat de recherche pour : <b><FONT COLOR=\"blue\">";
foreach($keywords as $value) {
   print "$value ";
}
echo "</font></b>";
}
echo "</center>";
 
//If users doesn't enter anything into search box tell them to.
if ($search == NULL){
echo "<center><b><FONT COLOR=\"red\">Merci d'entrez un mots cl�
    .</font></b><br /></center>";
} elseif ($search == '%'){
echo "<center><b><FONT COLOR=\"red\">Merci d'entrez un mots cl�.</font></b><br /></center>";
//If no results are returned print it
} elseif ($count <= 0){
echo "<center><b><FONT COLOR=\"red\">Aucun r�sultat dans la base de donn�e.</font></b><br /></center>";
} else {
echo "<table border=\"0\">";
echo "	<tr>";
echo "		<td width=\"200\"><b><font color=\"#000000\">Nom</font></td>";
echo "		<td width=\"200\"><b><font color=\"#000000\">Pr�nom</font></td>";
echo "		<td width=\"200\"><b><font color=\"#000000\">Date</font></td>";
echo "	</tr>";
echo "</table></center>";
while($row = mysql_fetch_array($result))
{
echo "<center><table border=\"0\">";
echo "	<tr>";
echo "		<td width=\"200\"><font color=\"#000000\"><a href=\"fiche.php?id=".$row['id']." \"> ".$row['nom']."</a></font></td>";
echo "		<td width=\"200\"><font color=\"#000000\"><a href=\"fiche.php?id=".$row['id']." \"> ".$row['prenom']."</a></font></td>";
echo "		<td width=\"200\"><font color=\"#000000\"><a href=\"fiche.php?id=".$row['id']." \"> ".$row['date']."</a></font></td>";
echo "	</tr>";
echo "</table></center>";
//end while
}
//end if
}
 
echo "</body>";
echo "</html></div>";
if ($search == NULL or $search == '%') {
} else {
//clear memory
mysql_free_result($result);
}
include("includes/footer.php");
?>