Erreur parse error: syntax

opyati -  
opyati Messages postés 3 Statut Membre -
Bonjour,
j'ai l'erreur suivante Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homez.466/opyati/www/test/index.php on line 76

aprés avoir inclus ce code
		<?php 
$fichier = fopen("index.php", "r+");
fputs($fichier, "<php //$_SERVER["REMOTE_ADDR"] connecte le $numjour $mois $annee a $heure h $minutes ?>\n");
fclose($dest);
?>

toutefois ma page est passer au validateur
http://validator.progysm.com/check.php#stat
Merci

3 réponses

le hollandais volant Messages postés 5294 Statut Membre 1 058
 
Salut !

Le validateur teste du code HTML.
Le code que tu as est du PHP, de la programmation.

L'erreur se situe au niveau du "REMOTE_ADDR" dont il faut échapper les doubles quotes :

<?php 
$fichier = fopen("index.php", "r+");
fputs($fichier, "<php //$_SERVER[\"REMOTE_ADDR\"] connecte le $numjour $mois $annee a $heure h $minutes ?>\n");
fclose($dest);
?>
0
opyati
 
Cela ne marche pas tout à fait j'obtient l'erreur suivante

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homez.466/opyati/www/test/index.php on line 76

merci
0
ReDLoG
 
fputs($fichier, $_SERVER['REMOTE_ADDR']." connecte le ". $numjour ." ". $mois ." ". $annee ." a ". $heure ." h ". $minutes ."\n");
0
opyati Messages postés 3 Statut Membre
 
Bonjour
voila ce que j'ai mis dans ma page
<?php
$fichier = fopen("index.php", "r+");
fputs($fichier,  $_SERVER['REMOTE_ADDR']." connecte le ". $numjour ." ". $mois ." ". $annee ." a ". $heure ." h ". $minutes .  "\n");
fclose($dest);
?>

voila ce qui s'affiche dans la page
Warning: fopen(index.php) [function.fopen]: failed to open stream: Permission non accordée in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 74

Notice: Undefined variable: numjour in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Notice: Undefined variable: mois in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Notice: Undefined variable: annee in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Notice: Undefined variable: heure in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Notice: Undefined variable: minutes in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Warning: fputs() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 75

Notice: Undefined variable: dest in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 76

Warning: fclose() expects parameter 1 to be resource, null given in /opt/lampp/htdocs/xampp/fjc-local/index.php on line 76

0