Mysql erreur

Fermé
jaydailfr Messages postés 121 Date d'inscription samedi 12 juillet 2008 Statut Membre Dernière intervention 24 juin 2009 - 19 juil. 2008 à 10:59
jaydailfr Messages postés 121 Date d'inscription samedi 12 juillet 2008 Statut Membre Dernière intervention 24 juin 2009 - 19 juil. 2008 à 11:51
Bonjour,
Bonjour,voil la mon erreur
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 '%%' at line 1
<html>
<form method="POST" action="">
Rechercher un mot : <input type="text" name="recherche">
<input type="SUBMIT" value="Search!">
</form>
</html>
<?php
//connection au serveur:
$cnx = mysql_connect( "localhost", "root", "" ) ;
// Récupère la variable
$recherche = isset($_POST['recherche']) ? $_POST['recherche'] : '';
// la requete mysql
$sql = mysql_query("SELECT name FROM spip_fuaj_adherents WHERE name LIKE %$recherche%") or die (mysql_error());

// affichage du résultat
while(list($name)=mysql_fetch_array($sql)){
echo 'Resultat de la recherche: '.$name.' <br />';
}

?>

6 réponses

Passarinho44 Messages postés 963 Date d'inscription mercredi 28 mai 2008 Statut Contributeur Dernière intervention 13 juin 2012 132
19 juil. 2008 à 11:04
Pas la peine de poster 2 fois ...
0
jlfond Messages postés 230 Date d'inscription lundi 24 janvier 2005 Statut Membre Dernière intervention 19 juin 2020 28
19 juil. 2008 à 11:13
Je mettrais des ' (simple quote) autour de '$recherche'
SELECT name FROM spip_fuaj_adherents WHERE name LIKE %'$recherche'%") or
0
jaydailfr Messages postés 121 Date d'inscription samedi 12 juillet 2008 Statut Membre Dernière intervention 24 juin 2009
19 juil. 2008 à 11:18
non tjs la meme erreur
0
Passarinho44 Messages postés 963 Date d'inscription mercredi 28 mai 2008 Statut Contributeur Dernière intervention 13 juin 2012 132
19 juil. 2008 à 11:18
Viens plutot jlfond =)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
jaydailfr Messages postés 121 Date d'inscription samedi 12 juillet 2008 Statut Membre Dernière intervention 24 juin 2009
19 juil. 2008 à 11:40
encore un petit pb , c 'est qu'il ne m 'affiche que la table nom , meme si je rajoute toute les autre table dans la requete
0
jaydailfr Messages postés 121 Date d'inscription samedi 12 juillet 2008 Statut Membre Dernière intervention 24 juin 2009
19 juil. 2008 à 11:51
ok c 'est bon ,j 'ai trouvé oupssss
0