Comme vous pouvez le voir en cliquant sur le bouton WWW ci dessous, je possède un petit site de recherche de personnes. Celui-ci repose sur un petit moteur de recher php mysql. Or, depuis que la recherche se fait sur une jointure sql, ce moteur à tendance à buguer. Je dit "a tendance à buguer" par ce que la recherche fonctionne environ une fois sur trois. Donc, deux fois sur trois, l'erreur suivante apparait.
CODE
Warning: mysql_query(): Unable to save result set in /home/ouetu/www/rechercher.php on line 31
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ouetu/www/rechercher.php on line 32
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ouetu/www/rechercher.php on line 32
La requete de recherche ressemble à ça:
CODE
$nbq = strlen($q);
$q = strtolower($q);
$q = trim($q);
$mots = str_replace('\'', ' ', $q);
$mots = str_replace(',', ' ', $mots);
$mots = str_replace(':', ' ', $mots);
$mots = str_replace('-', ' ', $mots);
$mots = str_replace('(', ' ', $mots);
$mots = str_replace(')', ' ', $mots);
$tab = explode(' ', $mots);
$nb = count($tab);
$sqlr= "SELECT PR.nom, PR.prenom, PR.pseudo, PA.affectations, PA.message FROM profils PR, parcours PA WHERE (PR.pseudo = PA.pseudo) AND (PR.afficher = 'oui') AND (PR.nom LIKE '%$tab[0]%' OR PR.prenom LIKE '%$tab[0]%' OR PA.affectations LIKE '%$tab[0]%')";
for($i = 1; $i < $nb;$i = $i +1)
{
$sqlr.=" AND (PR.nom LIKE '%$tab[$i]%' OR PR.prenom LIKE '%$tab[$i]%' OR PA.affectations LIKE '%$tab[$i]%')";
}
///$sqlr.=" ORDER BY PR.nom ASC";
$resr=mysql_query($sqlr, $db);///ligne31
$nbresult=mysql_num_rows($resr);///ligne32
$q = strtolower($q);
$q = trim($q);
$mots = str_replace('\'', ' ', $q);
$mots = str_replace(',', ' ', $mots);
$mots = str_replace(':', ' ', $mots);
$mots = str_replace('-', ' ', $mots);
$mots = str_replace('(', ' ', $mots);
$mots = str_replace(')', ' ', $mots);
$tab = explode(' ', $mots);
$nb = count($tab);
$sqlr= "SELECT PR.nom, PR.prenom, PR.pseudo, PA.affectations, PA.message FROM profils PR, parcours PA WHERE (PR.pseudo = PA.pseudo) AND (PR.afficher = 'oui') AND (PR.nom LIKE '%$tab[0]%' OR PR.prenom LIKE '%$tab[0]%' OR PA.affectations LIKE '%$tab[0]%')";
for($i = 1; $i < $nb;$i = $i +1)
{
$sqlr.=" AND (PR.nom LIKE '%$tab[$i]%' OR PR.prenom LIKE '%$tab[$i]%' OR PA.affectations LIKE '%$tab[$i]%')";
}
///$sqlr.=" ORDER BY PR.nom ASC";
$resr=mysql_query($sqlr, $db);///ligne31
$nbresult=mysql_num_rows($resr);///ligne32
Si quelqu'un avait un tuyau, ça me rendrait bien service. J'ai également pensé au fait que ma requète pouvait être trop longue mais je ne vois pas vraiment comment la simplifier.
Merci d'avance pour vos réponses,
Loïc.