Erreur php
Résolu
jaydailfr
Messages postés
121
Date d'inscription
Statut
Membre
Dernière intervention
-
jlfond Messages postés 230 Date d'inscription Statut Membre Dernière intervention -
jlfond Messages postés 230 Date d'inscription Statut Membre Dernière intervention -
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 />';
}
?>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 />';
}
?>
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 />';
}
?>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 />';
}
?>
A voir également:
- Erreur php
- Erreur 0x80070643 - Accueil - Windows
- Erreur 0x80070643 Windows 10 : comment résoudre le problème de la mise à jour KB5001716 - Accueil - Windows
- Expert php pinterest - Télécharger - Langages
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
5 réponses
Remplace :
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE %$recherche%"
Par
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE %" . $recherche . "%"
Là PHP trouvait "$recherche" dans ta requête et non pas sa valeur.
Essaie et dis moi si tu as encore l'erreur
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE %$recherche%"
Par
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE %" . $recherche . "%"
Là PHP trouvait "$recherche" dans ta requête et non pas sa valeur.
Essaie et dis moi si tu as encore l'erreur
maintenant il m 'affiche
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 '%aaaaaaaaaaaaa%' at line 1
avec aaaaaaaaa c 'est la valeur que j 'aii tapé dans le formulaire
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 '%aaaaaaaaaaaaa%' at line 1
avec aaaaaaaaa c 'est la valeur que j 'aii tapé dans le formulaire
Bon déjà il récupère la bonne valeur :p
Maintenant rajoute des simple quote ( ' ) autour les %
Comme ça :
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE '%" . $recherche . "%'"
Maintenant rajoute des simple quote ( ' ) autour les %
Comme ça :
"SELECT name FROM spip_fuaj_adherents WHERE name LIKE '%" . $recherche . "%'"
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question