besoin d'aide sur fonctions WHERE LIKE
bonjour
j'essaye doucement de comprendre comment marche le PHP avec un bouquin, je veux faire un moteur de recherche dans un tableau mais j'ai une erreur de syntaxe me dit mysql, je ne trouve pas ou, merci pour l'aide.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| <?php
include("variables.inc.php");
$liendb=mysql_connect ($bddserver, $bddlogin, $bddpassword)
or die("Connexion:".mysql_error());
mysql_select_db ($bdd)or die("Select db: ".mysql_error());
?>
<p align='left'><h1>:: début</p></h1>
<form action="2.php" method="GET">
<center><input type = "text" name="motclef"
value="<?php echo $_REQUEST['motclef'];?>"/>
<input type="submit" value="rechercher"/>
</form>
<br><br><br>
<table width=90% align=center border=5>
<tr>
<td class='intitule'>titre</td>
<td class= 'intitule'>real</td>
<td class='intitule'>annee</td>
<td class='intituleresum'>
<center>resumé</center></td>
<?php
$clause='';
if (isset($_REQUEST['motclef'])){
$clause.="WHERE titre LIKE".$_REQUEST['motclef']."'";
}
$sql = "SELECT*FROM film".$clause;
$resultat =mysql_query ($sql)or die("Query: ".mysql_error());
while ($film =mysql_fetch_array ($resultat))
{
$id= $film['num'];
$titre= $film ['titre'];
$rea= $film ['realisateur'];
$an= $film ['annee'];
$resum= $film ['resum'];
echo "<tr>";
echo "<td><a href='aptitre.php?id=$id'>".$titre."</a></td>";
echo "<td><a href='apbase.php?id=$id&rea=$rea'>".$rea."</a></td>";
echo '<td>'.$an.'</td>';
echo '<td>'.$resum.'</td>';
}
echo "</table>";
mysql_close ($liendb);
echo "</body>";
echo "</html>";
?> |
L'eereur rtournée est
Citation:
Query: 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 'LIKE''' at line 1