Parse error: syntax error, unexpected ';'
jamel
-
jamel -
jamel -
Bonjour,
j'é créé un motur de recherche avek un livre kome je komence a prog je sé pa koi fére. on m'affiche ca dans le browser :
Parse error: syntax error, unexpected ';' recherche.php on line 20
le code source c'est ca :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recherche</title>
</head>
<body>
<?php
$id=0;
if (!eregi('"', $mot)){
$mot=split('',$mot);
$id=1;
}else{
$mot=ereg_replace('["]', '', $mot);
$mot=ereg_replace('[\]', '', $mot);
}
if($id==1){
for($i=0;$i<count($mot);$i++){
$mot[$i]=ereg_replace('[\]','', $mot[$i];
}
}
$repertoire=opendir('.');
while($fichier=readdir($repertoire)){
$ok=is_file($fichier);
if($ok){
$open=fopen($fichier, 'r');
$contenu=fread($open, filesize($fichier));
if($id==1){
for($i=0; $i=count($mot);$i++){
if (eregi($mot[$i], $contenu)){
print("'$mot[$i]' a été trouvé dans <a href='affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
}else{
print("Aucune correspondance avec"$mot[$i]"n'a été trouvé dans $fichier.<br>");
}
print("<br><br>");
}
}
if($id==0){
if(eregi($mot, $contenu)){
$print("'$mot' a été trouvé dans <a href=''affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
}else{
print("Aucune correspondance avec"$mot[$i]"n'a été trouvé dans $fichier.<br>");
}
}
fclose($open);
}
}
?>
</body>
</html>
chokrane!
j'é créé un motur de recherche avek un livre kome je komence a prog je sé pa koi fére. on m'affiche ca dans le browser :
Parse error: syntax error, unexpected ';' recherche.php on line 20
le code source c'est ca :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Recherche</title>
</head>
<body>
<?php
$id=0;
if (!eregi('"', $mot)){
$mot=split('',$mot);
$id=1;
}else{
$mot=ereg_replace('["]', '', $mot);
$mot=ereg_replace('[\]', '', $mot);
}
if($id==1){
for($i=0;$i<count($mot);$i++){
$mot[$i]=ereg_replace('[\]','', $mot[$i];
}
}
$repertoire=opendir('.');
while($fichier=readdir($repertoire)){
$ok=is_file($fichier);
if($ok){
$open=fopen($fichier, 'r');
$contenu=fread($open, filesize($fichier));
if($id==1){
for($i=0; $i=count($mot);$i++){
if (eregi($mot[$i], $contenu)){
print("'$mot[$i]' a été trouvé dans <a href='affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
}else{
print("Aucune correspondance avec"$mot[$i]"n'a été trouvé dans $fichier.<br>");
}
print("<br><br>");
}
}
if($id==0){
if(eregi($mot, $contenu)){
$print("'$mot' a été trouvé dans <a href=''affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
}else{
print("Aucune correspondance avec"$mot[$i]"n'a été trouvé dans $fichier.<br>");
}
}
fclose($open);
}
}
?>
</body>
</html>
chokrane!
A voir également:
- Parse error: syntax error, unexpected ';'
- Fan error lenovo - Forum Refroidissement
- Eespt technical error - Forum Box et Streaming vidéo
- Pour ceux qui ont "LENOVO fan error au démarrage" - Forum PC portable
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- A javascript error occurred in the main process - Forum Matériel & Système
8 réponses
for($i=0;$i<count($mot);$i++){
$mot[$i]=ereg_replace('[\]','', $mot[$i];
}Tu as oublié de fermer une parenthèse avant le ";" de la seconde ligne.
Ton livre ne doit pas être très récent à voir ton code ... Pour information, tu as la structure foreach() qui te permet d'explorer un array ($mot) bien plus simplement.
https://www.php.net/manual/fr/control-structures.foreach.php
https://openclassrooms.com/fr/courses/918836-concevez-votre-site-web-avec-php-et-mysql#ss_part_2
mintenant ca marke ça :
Parse error: syntax error, unexpected T_VARIABLE in /home/venteart/public_html/recherche.php on line 34
Parse error: syntax error, unexpected T_VARIABLE in /home/venteart/public_html/recherche.php on line 34
print("Aucune correspondance avec"$mot[$i]"n'a été trouvé dans $fichier.<br>");Il faut échapper les guillemets à l'intérieur d'une chaine.echo 'Aucune correspondance avec "'.$mot[$i].'" n'a été trouvé dans '.$fichier.'<br/>';Va plutôt apprendre le PHP sur le Siteduzero.com, parce que la c'est vraiment du vieux code : fonctions ereg, print, exploration d'un array avec for alors qu'il y a foreach, ...
j'é fé ce que tu m'a di mé ca marke ca:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in recherche.php on line 32
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in recherche.php on line 32
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Ligne 34 :
echo 'Aucune correspondance avec "'.$mot[$i].'" n\'a été trouvé dans '.$fichier.'<br/>';Ligne 43 :
echo 'Aucune correspondance avec "'.$mot[$i].'" n\'a été trouvé dans '.$fichier.'.<br/>';Il ne devrait plus y avoir d'erreur de syntaxe.
justement, j'é fé aussi a l'otre mé ca fé toujour la meme chose.
est qu'il fodré changer le print("'$mot[$i]' a été trouvé dans <a href='affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
en echo comme l'otre? tout a l'heure j'é ca mé ca n'a pas marché:
echo '"'.$mot[$i].'" a été trouvé dans <a href="affichage.php?fichier=$fichier&mot=$mot[$i]" taget="_blank">'.$fichier.'</a><br />';
est qu'il fodré changer le print("'$mot[$i]' a été trouvé dans <a href='affichage.php?fichier=$fichier&$mot[$i]' target='_blank'>$fichier</a><br>");
en echo comme l'otre? tout a l'heure j'é ca mé ca n'a pas marché:
echo '"'.$mot[$i].'" a été trouvé dans <a href="affichage.php?fichier=$fichier&mot=$mot[$i]" taget="_blank">'.$fichier.'</a><br />';