erreur du type Warning: mysql_fetch_assoc(): 4 is not a vali
Posté : 22 févr. 2012, 17:23
Mesdames Messieurs bonjour à tous,
j'ai ce code ci qui me renvoit une erreur et je ne sais pas comment l’éradiquer.
ceci est un moteur de recherche censé affiché les enregistrements de ma bdd.
le code du formulaire est classique:
suivante.
Si quelqu'un saurait m'aider?
Par avance merci.
cdt sp.
j'ai ce code ci qui me renvoit une erreur et je ne sais pas comment l’éradiquer.
ceci est un moteur de recherche censé affiché les enregistrements de ma bdd.
le code du formulaire est classique:
<form action="results.php" method="get" name="search" id="search">
<label for="title">Recherche :</label>
<input type="text" name="n_doss" id="n_doss">
<input type="submit" name="submit" id="submit" value="Go !">
</form>
l'erreur renvoyée est la suivante:Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result
la page qui analyse les données reçues et qui renvoit les résultats de ma bdd est la suivante.
<?php require_once('Connections/localhost.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;
}
}
$maxRows_Recordset1 = 25;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$colname_Recordset1 = "-1";
if (isset($_GET['n_doss'])) {
$colname_Recordset1 = $_GET['n_doss'];
}
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = sprintf("SELECT * FROM creance WHERE code_client LIKE %s OR id LIKE %s OR n_doss LIKE %s OR ref_client LIKE %s OR raison_sociale LIKE %s OR siret LIKE %s OR nom LIKE %s OR prenom LIKE %s OR principal LIKE %s OR solde_restant_du LIKE %s", GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_free_result($Recordset1);
?>
<?php do { ?>
<table width="100%" border="1">
<tr>
<th scope="col">ID</th>
<th scope="col">CLIENT</th>
<th scope="col">DOSSIER</th>
<th scope="col">REFERENCE CLIENT</th>
<th scope="col">TYPE</th>
<th scope="col">DEBITEUR</th>
<th scope="col">CP</th>
<th scope="col">VILLE</th>
<th scope="col">PRINCIPAL</th>
<th scope="col">SOLDE</th>
</tr>
<tr>
<td><?php echo $row_Recordset1['id']; ?></td>
<td><?php echo $row_Recordset1['code_client']; ?></td>
<td><?php echo $row_Recordset1['n_doss']; ?></td>
<td><?php echo $row_Recordset1['ref_client']; ?></td>
<td><?php echo $row_Recordset1['type']; ?></td>
<td><?php echo $row_Recordset1['raison_sociale']; ?><?php echo $row_Recordset1['nom']; ?><?php echo $row_Recordset1['prenom']; ?></td>
<td><?php echo $row_Recordset1['code_postal']; ?></td>
<td><?php echo $row_Recordset1['ville']; ?></td>
<td><?php echo $row_Recordset1['principal']; ?></td>
<td><?php echo $row_Recordset1['solde_restant_du']; ?></td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
ça fais deux bonnes heures que je tournes en rond, j'ai tout passé en revue et je ne vois pas ce qui cloche.Si quelqu'un saurait m'aider?
Par avance merci.
cdt sp.