Au secour erreur sql
Résolu
bretonm2004
Messages postés
319
Date d'inscription
Statut
Membre
Dernière intervention
-
bretonm2004 Messages postés 319 Date d'inscription Statut Membre Dernière intervention -
bretonm2004 Messages postés 319 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai cette erreur sql quand j'envoie ma requete de recherche pouvez vous m aisder svp
voici le code
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 'WHERE marque LIKE '%%' AND modele LIKE '%%' AND annee LIKE '%%'' at line 1
voici le script
<form method="post">
<table align="center" width="800" border="1">
<tr>
<td width="99"> </td>
<td width="227">Marque: <select onchange="if(this.selectedIndex == 65) document.getElementById('autres').style.display = 'block';
else document.getElementById('autres').style.display = 'none';" name="marque">
<option>Sélectionnez</option>
<option>Acura</option>
<option>Alfa Romeo</option>
<option>AMC</option>
<option>Aston Martin</option>
<option>Audi</option>
<option>Bentley</option>
<option>BMW</option>
<option>Bugatti</option>
<option>Buick</option>
<option>Cadillac</option>
<option>Chevrolet</option>
<option>Chrysler</option>
<option>Daewoo</option>
<option>Daihatsu</option>
<option>Datsun</option>
<option>Dodge</option>
<option>Eagle</option>
<option>Ferrari</option>
<option>Fiat</option>
<option>Ford</option>
<option>Geo</option>
<option>GMC</option>
<option>Honda</option>
<option>Hummer</option>
<option>Hyundai</option>
<option>Infiniti</option>
<option>International Harvester</option>
<option>Isuzu</option>
<option>Jaguar</option>
<option>Jeep</option>
<option>Kia</option>
<option>Lamborghini</option>
<option>Land Rover</option>
<option>Lexus</option>
<option>Lincoln</option>
<option>Lotus</option>
<option>Maserati</option>
<option>Maybach</option>
<option>Mazda</option>
<option>Mercedes-Benz</option>
<option>Mercury</option>
<option>MG</option>
<option>Mini</option>
<option>Mitsubishi</option>
<option>Nissan</option>
<option>Oldsmobile</option>
<option>Opel</option>
<option>Peugeot</option>
<option>Plymouth</option>
<option>Pontiac</option>
<option>Porshe</option>
<option>Renault</option>
<option>Rolls-Royce</option>
<option>Saab</option>
<option>Saturn</option>
<option>Scion</option>
<option>Smart</option>
<option>Shelby</option>
<option>Subaru</option>
<option>Suzuki</option>
<option>Toyota</option>
<option>Triumph</option>
<option>Volkswagen</option>
<option>Volvo</option>
<option>Autre</option>
</select>
<input id="autres" type="text" name="autres" style="display:none;" />
</td>
<td width="239">Modèle:<input type="text" size="20" name="modele" value="" /> </td>
<td width="111">Année:<select name="annee">
<option></option>
<option>1985</option>
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select></td>
<td width="84"><input name="envoyer" value="Rechercher" type="submit" /> </td>
</tr>
</table>
</form>
<p><table align="center" width="700" border="0">
<tr>
<td width="375" height="39"><img src="images/barre1.png" width="375" height="42" /></td>
<td width="151"><img src="images/barre2.png" width="150" height="40" /></td>
<td width="152"><img src="images/barre3.png" width="150" height="40" /></td>
</tr>
</table>
<?php
if (isset($_POST['envoyer']))
{
/* On initialise les variables */
$limit=5; // Donc 5 articles par page
// Sur quel page on est ?
if (isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page=0;
}
// Maintenant le navigateur de pages
// Affiche le page par page avec ses liens
// Variable nombre d'enreg par page
$debut=$page*$limit; // Debut est egale a page x limit donc page 2 sera egale a 10
mysql_connect('localhost', 'ccccccccc', 'cccccccc');
mysql_select_db("cccccccccccccc");
$sql = "SELECT * FROM avendrepubliee ORDER BY id DESC LIMIT ".$debut.", ".$limit." WHERE marque LIKE '%$marque%' AND modele LIKE '%$modele%' AND annee LIKE '%$anne%' ";
$req = mysql_query($sql) or die(mysql_error());
$count = mysql_result(mysql_query("SELECT count(*) FROM avendrepubliee"), 0);
// Compte le nombre de champ
$nav_page=true; // J'indique une variable vide, car si je ne le fais pas, j'ai des erreurs
if ($page>0)
{
$precedent=$page-1;
$nav_page.='<a href="rechercheavendre.php?page='.$precedent.'">PRECEDENT</a> ';
}
$i=0; // On initialise $i => Page
$j=1; // On initialise $j => La page afficher
if($count>$limit)
{
while($i<ceil($count/$limit))
{
// C'est une page avant ou après la position actuel
if($i!=$page){$nav_page.='<a href="rechercheavendre.php?page='.$i.'">'.$j.'</a>';}
// C'est la page en cours
else { $nav_page.=" <b>".$j."</b> ";}
$i++;$j++;
}
}
if($debut+$limit<$count)
{
$suivant=$page+1;
$nav_page.=' <a href="rechercheavendre.php?page='.$suivant.'">SUIVANT</a>';
}
/* Fin initialisation */
echo "<table align='center' width='700' border='0'>";
while($row = mysql_fetch_array($req))
{
$id=$row['id']; $typedannonce=$row['typedannonce'];
$marque=$row['marque']; $autres=$row['autres'];
$modele=$row['modele']; $prix=$row['prix'];
$negociable=$row['negociable']; $annee=$row['annee'];
$etat=$row['etat']; $carburant=$row['carburant'];
$kilometrage=$row['kilometrage']; $transmission=$row['transmission'];
$immatricule=$row['immatricule']; $climatisation=$row['climatisation'];
$audio=$row['audio']; $cylindre=$row['cylindre'];
$puissance=$row['puissance']; $consommation=$row['consommation'];
$couleurinterieure=$row['couleurinterieure']; $couleurexterieure=$row['couleurexterieure'];
$email=$row['email']; $message=$row['message']; $date=$row['date']; $image=$row['image'];
echo "<tr>
<td width='114'>
<center>
<a href='photos/avendrenp/".$row['image1']." ' alt='Voir image en grand'>
<img src='photos/avendrenp/".$row['image1']." ' width='75' />
</a>
</center></td>
<td width='258' height='78'>".$row['marque']." ".$row['autres']." ".$row['modele']." ".$row['annee']." ".$row['negociable']."</td>
<td align='center' width='147'>".$row['prix']."</td>
<td align='center' width='153'>".$row['date']."</td>
</tr>";
}
echo "</table>";
// Hop on affiche le navigateur
echo $nav_page;
}
else
{
/* On initialise les variables */
$limit=5; // Donc 5 articles par page
// Sur quel page on est ?
if (isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page=0;
}
// Maintenant le navigateur de pages
// Affiche le page par page avec ses liens
// Variable nombre d'enreg par page
$debut=$page*$limit; // Debut est egale a page x limit donc page 2 sera egale a 10
mysql_connect('localhost', 'ccccc', 'cccc');
mysql_select_db("accccc");
$sql = "SELECT * FROM avendrepubliee ORDER BY id DESC LIMIT ".$debut.", ".$limit." ";
$req = mysql_query($sql) or die(mysql_error());
$count = mysql_result(mysql_query("SELECT count(*) FROM avendrepubliee"), 0);
// Compte le nombre de champ
$nav_page=true; // J'indique une variable vide, car si je ne le fais pas, j'ai des erreurs
if ($page>0)
{
$precedent=$page-1;
$nav_page.='<a href="rechercheavendre.php?page='.$precedent.'">PRECEDENT</a> ';
}
$i=0; // On initialise $i => Page
$j=1; // On initialise $j => La page afficher
if($count>$limit)
{
while($i<ceil($count/$limit))
{
// C'est une page avant ou après la position actuel
if($i!=$page){$nav_page.='<a href="rechercheavendre.php?page='.$i.'">'.$j.'</a>';}
// C'est la page en cours
else { $nav_page.=" <b>".$j."</b> ";}
$i++;$j++;
}
}
if($debut+$limit<$count)
{
$suivant=$page+1;
$nav_page.=' <a href="rechercheavendre.php?page='.$suivant.'">SUIVANT</a>';
}
/* Fin initialisation */
echo "<table align='center' width='700' border='0'>";
while($row = mysql_fetch_array($req))
{
$id=$row['id']; $typedannonce=$row['typedannonce'];
$marque=$row['marque']; $autres=$row['autres'];
$modele=$row['modele']; $prix=$row['prix'];
$negociable=$row['negociable']; $annee=$row['annee'];
$etat=$row['etat']; $carburant=$row['carburant'];
$kilometrage=$row['kilometrage']; $transmission=$row['transmission'];
$immatricule=$row['immatricule']; $climatisation=$row['climatisation'];
$audio=$row['audio']; $cylindre=$row['cylindre'];
$puissance=$row['puissance']; $consommation=$row['consommation'];
$couleurinterieure=$row['couleurinterieure']; $couleurexterieure=$row['couleurexterieure'];
$email=$row['email']; $message=$row['message']; $date=$row['date']; $image=$row['image'];
echo "<tr>
<td width='114'>
<center>
<a href='photos/avendrenp/".$row['image1']." ' alt='Voir image en grand'>
<img src='photos/avendrenp/".$row['image1']." ' width='75' />
</a>
</center></td>
<td width='258' height='78'>".$row['marque']." ".$row['autres']." ".$row['modele']." ".$row['annee']." ".$row['negociable']."</td>
<td align='center' width='147'>".$row['prix']."</td>
<td align='center' width='153'>".$row['date']."</td>
</tr>";
}
echo "</table>";
// Hop on affiche le navigateur
echo $nav_page;
}
?>
j'ai cette erreur sql quand j'envoie ma requete de recherche pouvez vous m aisder svp
voici le code
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 'WHERE marque LIKE '%%' AND modele LIKE '%%' AND annee LIKE '%%'' at line 1
voici le script
<form method="post">
<table align="center" width="800" border="1">
<tr>
<td width="99"> </td>
<td width="227">Marque: <select onchange="if(this.selectedIndex == 65) document.getElementById('autres').style.display = 'block';
else document.getElementById('autres').style.display = 'none';" name="marque">
<option>Sélectionnez</option>
<option>Acura</option>
<option>Alfa Romeo</option>
<option>AMC</option>
<option>Aston Martin</option>
<option>Audi</option>
<option>Bentley</option>
<option>BMW</option>
<option>Bugatti</option>
<option>Buick</option>
<option>Cadillac</option>
<option>Chevrolet</option>
<option>Chrysler</option>
<option>Daewoo</option>
<option>Daihatsu</option>
<option>Datsun</option>
<option>Dodge</option>
<option>Eagle</option>
<option>Ferrari</option>
<option>Fiat</option>
<option>Ford</option>
<option>Geo</option>
<option>GMC</option>
<option>Honda</option>
<option>Hummer</option>
<option>Hyundai</option>
<option>Infiniti</option>
<option>International Harvester</option>
<option>Isuzu</option>
<option>Jaguar</option>
<option>Jeep</option>
<option>Kia</option>
<option>Lamborghini</option>
<option>Land Rover</option>
<option>Lexus</option>
<option>Lincoln</option>
<option>Lotus</option>
<option>Maserati</option>
<option>Maybach</option>
<option>Mazda</option>
<option>Mercedes-Benz</option>
<option>Mercury</option>
<option>MG</option>
<option>Mini</option>
<option>Mitsubishi</option>
<option>Nissan</option>
<option>Oldsmobile</option>
<option>Opel</option>
<option>Peugeot</option>
<option>Plymouth</option>
<option>Pontiac</option>
<option>Porshe</option>
<option>Renault</option>
<option>Rolls-Royce</option>
<option>Saab</option>
<option>Saturn</option>
<option>Scion</option>
<option>Smart</option>
<option>Shelby</option>
<option>Subaru</option>
<option>Suzuki</option>
<option>Toyota</option>
<option>Triumph</option>
<option>Volkswagen</option>
<option>Volvo</option>
<option>Autre</option>
</select>
<input id="autres" type="text" name="autres" style="display:none;" />
</td>
<td width="239">Modèle:<input type="text" size="20" name="modele" value="" /> </td>
<td width="111">Année:<select name="annee">
<option></option>
<option>1985</option>
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select></td>
<td width="84"><input name="envoyer" value="Rechercher" type="submit" /> </td>
</tr>
</table>
</form>
<p><table align="center" width="700" border="0">
<tr>
<td width="375" height="39"><img src="images/barre1.png" width="375" height="42" /></td>
<td width="151"><img src="images/barre2.png" width="150" height="40" /></td>
<td width="152"><img src="images/barre3.png" width="150" height="40" /></td>
</tr>
</table>
<?php
if (isset($_POST['envoyer']))
{
/* On initialise les variables */
$limit=5; // Donc 5 articles par page
// Sur quel page on est ?
if (isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page=0;
}
// Maintenant le navigateur de pages
// Affiche le page par page avec ses liens
// Variable nombre d'enreg par page
$debut=$page*$limit; // Debut est egale a page x limit donc page 2 sera egale a 10
mysql_connect('localhost', 'ccccccccc', 'cccccccc');
mysql_select_db("cccccccccccccc");
$sql = "SELECT * FROM avendrepubliee ORDER BY id DESC LIMIT ".$debut.", ".$limit." WHERE marque LIKE '%$marque%' AND modele LIKE '%$modele%' AND annee LIKE '%$anne%' ";
$req = mysql_query($sql) or die(mysql_error());
$count = mysql_result(mysql_query("SELECT count(*) FROM avendrepubliee"), 0);
// Compte le nombre de champ
$nav_page=true; // J'indique une variable vide, car si je ne le fais pas, j'ai des erreurs
if ($page>0)
{
$precedent=$page-1;
$nav_page.='<a href="rechercheavendre.php?page='.$precedent.'">PRECEDENT</a> ';
}
$i=0; // On initialise $i => Page
$j=1; // On initialise $j => La page afficher
if($count>$limit)
{
while($i<ceil($count/$limit))
{
// C'est une page avant ou après la position actuel
if($i!=$page){$nav_page.='<a href="rechercheavendre.php?page='.$i.'">'.$j.'</a>';}
// C'est la page en cours
else { $nav_page.=" <b>".$j."</b> ";}
$i++;$j++;
}
}
if($debut+$limit<$count)
{
$suivant=$page+1;
$nav_page.=' <a href="rechercheavendre.php?page='.$suivant.'">SUIVANT</a>';
}
/* Fin initialisation */
echo "<table align='center' width='700' border='0'>";
while($row = mysql_fetch_array($req))
{
$id=$row['id']; $typedannonce=$row['typedannonce'];
$marque=$row['marque']; $autres=$row['autres'];
$modele=$row['modele']; $prix=$row['prix'];
$negociable=$row['negociable']; $annee=$row['annee'];
$etat=$row['etat']; $carburant=$row['carburant'];
$kilometrage=$row['kilometrage']; $transmission=$row['transmission'];
$immatricule=$row['immatricule']; $climatisation=$row['climatisation'];
$audio=$row['audio']; $cylindre=$row['cylindre'];
$puissance=$row['puissance']; $consommation=$row['consommation'];
$couleurinterieure=$row['couleurinterieure']; $couleurexterieure=$row['couleurexterieure'];
$email=$row['email']; $message=$row['message']; $date=$row['date']; $image=$row['image'];
echo "<tr>
<td width='114'>
<center>
<a href='photos/avendrenp/".$row['image1']." ' alt='Voir image en grand'>
<img src='photos/avendrenp/".$row['image1']." ' width='75' />
</a>
</center></td>
<td width='258' height='78'>".$row['marque']." ".$row['autres']." ".$row['modele']." ".$row['annee']." ".$row['negociable']."</td>
<td align='center' width='147'>".$row['prix']."</td>
<td align='center' width='153'>".$row['date']."</td>
</tr>";
}
echo "</table>";
// Hop on affiche le navigateur
echo $nav_page;
}
else
{
/* On initialise les variables */
$limit=5; // Donc 5 articles par page
// Sur quel page on est ?
if (isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page=0;
}
// Maintenant le navigateur de pages
// Affiche le page par page avec ses liens
// Variable nombre d'enreg par page
$debut=$page*$limit; // Debut est egale a page x limit donc page 2 sera egale a 10
mysql_connect('localhost', 'ccccc', 'cccc');
mysql_select_db("accccc");
$sql = "SELECT * FROM avendrepubliee ORDER BY id DESC LIMIT ".$debut.", ".$limit." ";
$req = mysql_query($sql) or die(mysql_error());
$count = mysql_result(mysql_query("SELECT count(*) FROM avendrepubliee"), 0);
// Compte le nombre de champ
$nav_page=true; // J'indique une variable vide, car si je ne le fais pas, j'ai des erreurs
if ($page>0)
{
$precedent=$page-1;
$nav_page.='<a href="rechercheavendre.php?page='.$precedent.'">PRECEDENT</a> ';
}
$i=0; // On initialise $i => Page
$j=1; // On initialise $j => La page afficher
if($count>$limit)
{
while($i<ceil($count/$limit))
{
// C'est une page avant ou après la position actuel
if($i!=$page){$nav_page.='<a href="rechercheavendre.php?page='.$i.'">'.$j.'</a>';}
// C'est la page en cours
else { $nav_page.=" <b>".$j."</b> ";}
$i++;$j++;
}
}
if($debut+$limit<$count)
{
$suivant=$page+1;
$nav_page.=' <a href="rechercheavendre.php?page='.$suivant.'">SUIVANT</a>';
}
/* Fin initialisation */
echo "<table align='center' width='700' border='0'>";
while($row = mysql_fetch_array($req))
{
$id=$row['id']; $typedannonce=$row['typedannonce'];
$marque=$row['marque']; $autres=$row['autres'];
$modele=$row['modele']; $prix=$row['prix'];
$negociable=$row['negociable']; $annee=$row['annee'];
$etat=$row['etat']; $carburant=$row['carburant'];
$kilometrage=$row['kilometrage']; $transmission=$row['transmission'];
$immatricule=$row['immatricule']; $climatisation=$row['climatisation'];
$audio=$row['audio']; $cylindre=$row['cylindre'];
$puissance=$row['puissance']; $consommation=$row['consommation'];
$couleurinterieure=$row['couleurinterieure']; $couleurexterieure=$row['couleurexterieure'];
$email=$row['email']; $message=$row['message']; $date=$row['date']; $image=$row['image'];
echo "<tr>
<td width='114'>
<center>
<a href='photos/avendrenp/".$row['image1']." ' alt='Voir image en grand'>
<img src='photos/avendrenp/".$row['image1']." ' width='75' />
</a>
</center></td>
<td width='258' height='78'>".$row['marque']." ".$row['autres']." ".$row['modele']." ".$row['annee']." ".$row['negociable']."</td>
<td align='center' width='147'>".$row['prix']."</td>
<td align='center' width='153'>".$row['date']."</td>
</tr>";
}
echo "</table>";
// Hop on affiche le navigateur
echo $nav_page;
}
?>
A voir également:
- Au secour erreur sql
- Erreur 0x80070643 - Accueil - Windows
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
- Comment recuperer whatsapp supprimé par erreur - Guide
- Iptv erreur de lecture - Forum TV & Vidéo
$annee=$_POST['annee'];
$modele=$_POST['modele'];
j'ai ajouté ca et toujours la meme erreur
j'ai ca comme erreur a la place
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 'WHERE marque LIKE '%Hyundai%' AND modele LIKE '%dffffff%' AND annee LIKE '%2009%' at line 1
toute les varriables ont une valeur