Bonjour,

j'essai de faire une pagination,
dans un formulaire je fait passer les variable en seision.
seulement quand je clique sur suivant de la pigination j'ai ce message
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%%' LIMIT 0, 10' at line 1
alors que la 1er page de resultat de la pagination est corect.
Je constate egalement en effectuant un echo de ma seission, que la seission ne passe s'affiche pas dans la page suivante alors que dans la premiere oui.

Lorsque ma requete est ecrite en dur tout marche, comment puis je faire ?
Quel sont les solutions pour afficher le resultat d'un formailre de recherche d 'une requete sql en pagination.

Merci d'avance, cordialement.


Le formulaire
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
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recherche dans la videothèque</title>
<style type="text/css">
<!--
.Style1 {color: #FF0000}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
body p {
	text-align: center;
}
-->
</style>
</head>
 
<body>
<p> 
 
 
</p>
    <h3 align="center">&nbsp;</h3>
    <h3 align="center">Recherche d'un nom dans l'annuaire t&eacute;l&eacute;phonique<br />
      <br />
    </h3>
<p align="center">Veuillez indiquer ci-dessous une cat&eacute;gorie de recherche puis un mot, un phrase &agrave; rechercher dans le champs rechercher .     
<p align="center">(<span class="Style1">*</span>)  obligatoire.
<?php session_start(recherche_videotheque); // au début de chaque page ?>
<form action="recherche-test-regis-2-3.php" method='post'>
        </p>
    <table align="center" border="0">
    <tr>
    <td>Cat&eacute;gorie  (<span class="Style1">*</span> )</td>
    <td><select name="recherche2" value="">
				<option value="0">-- SELECTIONNEZ --</option>
				<option value="id">Id</option>
				<option value="date_creation_fiche">Date de création de la fiche</option>
				<option value="titre">Titre</option>
				<option value="Type">Type</option>
				<option value="genre">Genre</option>
				<option value="duree">Duree</option>
				<option value="acteurs">Acteurs</option>
				<option value="realisateur">Realisateur</option>
				<option value="producteur">Producteur</option>
				<option value="origine">Origine</option>
				<option value="titre_original">Titre original</option>
				<option value="histoire">Histoire</option>
				<option value="codec">Codec</option>
				<option value="qualite_video">Qualite video</option>
                <option value="qualite_sonore">Qualite sonore</option>
                <option value="date">Date</option>
				<option value="lien">Lien</option>
                <option value="lien_http">Lien http</option>
			</select></td>
    <td>&nbsp;</td>
     </tr>
    <tr>
      <td>Rechercher (<span class="Style1">*</span> )</td>
      <td><input type="text" name="recherche1" size="20" maxlength="20" /></td>
      <td><input type="submit" name"envoyer-recherche-approximative" value="Rechercher"></td>
    </tr>
</table>
 
	</p>
    <h3 align="center">&nbsp;</h3>
 
 
<br />
<br />
 
</body>
</html>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="../accueil.php">[Accueil]</a> - <a href="index.php">[</a><a href="../contacts.php">Contacts</a><a href="index.php">]</a> - <a href="carnet.php">[Afficher]</a> - <a href="modifier une entree.php">[Modifier]</a> </span></p>
<p>&nbsp;</p>
</body>
</html>
La page de pagination
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
 
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recherche dans la videothèque</title>
<style type="text/css">
<!--
.Style1 {color: #FF0000}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
body p {
	text-align: center;
}
-->
</style>
</head>
 
<body>
<p>
 
 
 
<p align="center"><?php session_start(recherche_videotheque); 
 
$_SESSION['recherche2'] = $_POST['recherche2'] ;
$_SESSION['recherche1'] = $_POST['recherche1'] ;
?>
 
 
<p align="center">
<?PHP
$nom = $_POST['recherche1']; 
$nom_colone = $_POST['recherche2']; 
 
echo  "<br/><div align= 'center'>";
	echo "Récapitulatif des informations saisies<BR>\n
	<UL>
	<LI>1 / Resultat variable --> Nom rubrique :  $nom_colone</LI>
	<LI>2 /Resultat variable --> Nom du mot clé :  $nom</LI>
	</UL>
	";
?>
 
<?php 
require_once('adresses.php'); 
 
 
 
/* ------------------ Connexion a la BDD avec login.php ------------------ */
require ('login.php');
$connexion = mysql_connect($hote, $login, $pass) or die("Erreur de connexion...") ;
$req = mysql_select_db($bdd, $connexion) or die("Erreur de connexion...") ;
 
/* ------------------ Configuration table Mysql ------------------ */
$nom_table = ("videotheque");
 
?>
</p>
<p>
 
 
	</p>
    <h3 align="center">&nbsp;</h3>
    <h3 align="center">Recherche d'un nom dans l'annuaire t&eacute;l&eacute;phonique<br />
      <br />
        </p>
    </p>
<h3 align="center">&nbsp;</h3>
 
    <!--------------------------------------- DEBUT PIGINATION ------------------------------------------->
 
<?php require_once("contacts.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$currentPage = $_SERVER["PHP_SELF"];
 
$maxRows_liste_detail = 10;
$pageNum_liste_detail = 0;
if (isset($_GET['pageNum_liste_detail'])) {
  $pageNum_liste_detail = $_GET['pageNum_liste_detail'];
}
$startRow_liste_detail = $pageNum_liste_detail * $maxRows_liste_detail;
 
mysql_select_db($database_Adresses, $Adresses);
 
 
 
 
$query_liste_detail = "SELECT * FROM $nom_table WHERE ".$_SESSION['recherche2']." LIKE '%".$_SESSION['recherche1']."%'"; 
$query_limit_liste_detail = sprintf("%s LIMIT %d, %d", $query_liste_detail, $startRow_liste_detail, $maxRows_liste_detail);
$liste_detail = mysql_query($query_limit_liste_detail, $Adresses) or die(mysql_error());
$row_liste_detail = mysql_fetch_assoc($liste_detail);
 
if (isset($_GET['totalRows_liste_detail'])) {
  $totalRows_liste_detail = $_GET['totalRows_liste_detail'];
} else {
  $all_liste_detail = mysql_query($query_liste_detail);
  $totalRows_liste_detail = mysql_num_rows($all_liste_detail);
}
$totalPages_liste_detail = ceil($totalRows_liste_detail/$maxRows_liste_detail)-1;
 
$queryString_liste_detail = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_liste_detail") == false && 
        stristr($param, "totalRows_liste_detail") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_liste_detail = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_liste_detail = sprintf("&totalRows_liste_detail=%d%s", $totalRows_liste_detail, $queryString_liste_detail);
?>
<table border="1" align="center">
      <tr>
        <td>Id</td>
        <td>Titre</td>
        <td>Genre</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><a href="detail.php?recordID=<?php echo $row_liste_detail['id']; ?>"> <?php echo $row_liste_detail['id']; ?>&nbsp; </a></td>
          <td><?php echo $row_liste_detail['titre']; ?>&nbsp; </td>
          <td><?php echo $row_liste_detail['genre']; ?>&nbsp; </td>
        </tr>
    <?php } while ($row_liste_detail = mysql_fetch_assoc($liste_detail)); ?>
    </table>
    <br />
    <table border="0" align="center">
      <tr>
        <td><?php if ($pageNum_liste_detail > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_liste_detail=%d%s", $currentPage, 0, $queryString_liste_detail); ?>">Premier</a>
            <?php } // Show if not first page ?></td>
        <td><?php if ($pageNum_liste_detail > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_liste_detail=%d%s", $currentPage, max(0, $pageNum_liste_detail - 1), $queryString_liste_detail); ?>">Précédent</a>
            <?php } // Show if not first page ?></td>
        <td><?php if ($pageNum_liste_detail < $totalPages_liste_detail) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_liste_detail=%d%s", $currentPage, min($totalPages_liste_detail, $pageNum_liste_detail + 1), $queryString_liste_detail); ?>">Suivant</a>
            <?php } // Show if not last page ?></td>
        <td><?php if ($pageNum_liste_detail < $totalPages_liste_detail) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_liste_detail=%d%s", $currentPage, $totalPages_liste_detail, $queryString_liste_detail); ?>">Dernier</a>
            <?php } // Show if not last page ?></td>
      </tr>
    </table>
    <br />
 
</body>
</html>
<?php
mysql_free_result($liste_detail);
 
?>
 
 
    <!--------------------------------------- FIN PIGNATION ------------------------------------------->
 
 
 
 
 
 
 
 
 
 
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="../accueil.php">[Accueil]</a> - <a href="index.php">[</a><a href="../contacts.php">Contacts</a><a href="index.php">]</a> - <a href="carnet.php">[Afficher]</a> - <a href="modifier une entree.php">[Modifier]</a> </span></p>
<p>&nbsp;</p>
</body>
</html>
<?php //mysql_close(); 
 
?>