Erreurs avec fputs
Résolu
Tobi86
Messages postés
405
Date d'inscription
Statut
Membre
Dernière intervention
-
ElementW Messages postés 4814 Date d'inscription Statut Contributeur Dernière intervention -
ElementW Messages postés 4814 Date d'inscription Statut Contributeur Dernière intervention -
Bonsoir a toues, voilà je ne comprends pas pourquoi mon programme ne fonctionne pas ... Pourriez-vous m'éclairer ?
<?php include("connexion.php"); $myfile="list-logs.php"; $req="SELECT DISTINCT id, name, first_name, mail, login, password FROM users_profs"; $res = $connect->query($req); //var_dump($req); $i=1; $fichier = 'chemin_du_fichier/fichier.txt'; if( file_exists ( $myfile)) unlink( $myfile ); //Traitement du résultat while($row=$res->fetch(PDO::FETCH_ASSOC)) { fputs($myfile, "$id".$i."=".$row['id']."\n"); fputs($myfile, "$name".$i."=".$row['name']."\n"); fputs($myfile, "$firstName".$i."=".$row['first_name']."\n"); fputs($myfile, "$mail".$i."=".$row['mail']."\n"); fputs($myfile, "$login".$i."=".$row['login']."\n"); fputs($myfile, "$password".$i."=".$row['password']."\n"); $i=$i+1; } ?>
A voir également:
- Erreurs avec fputs
- La session « perfdiag logger » s’est arrêtée avec l’erreur suivante : 0xc0000188 ✓ - Forum Virus
- Une ou plusieurs erreurs sont présentes dans le formulaire. merci de rectifier votre saisie en vous aidant des aides disponibles. - Forum VB / VBA
- BSOD + BIOS + Erreurs - Forum Windows
- Impossible d'installer java les commutateurs suivants comportent des erreurs ✓ - Forum Java
- Microsoft windows ne repond pas - Forum Windows
2 réponses
'lut,
fputsprend un descripteur de fichier en premier paramètre, pas le nom du fichier. Donc il faut faire un
fopenet un
fclosepour que ça marche:
$myfile=fopen("list-logs.php", "w"); ... // Le reste de ton code ... fclose($myfile);
PHP Warning: file_exists() expects parameter 1 to be string, resource given in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 12 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24 PHP Notice: Undefined variable: id in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 19 PHP Notice: Undefined variable: name in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 20 PHP Notice: Undefined variable: firstName in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 21 PHP Notice: Undefined variable: mail in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 22 PHP Notice: Undefined variable: login in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 23 PHP Notice: Undefined variable: password in /home/thibaultc/Documents/www/appli/log/actua-list-logs.php on line 24
Il faut que tu changes tes doubles guillemets en guillemets simples ('), sinon PHP essaie d'interpréter les variables dedans, d'où la masse d'erreurs.
Pour l'erreur du
Pour l'erreur du
file_exists(); reviens à ton code précédent et changes-le comme ceci:
$myfilename="list-logs.php"; ... if( file_exists ( $myfilename)) unlink( $myfilename ); $myfile=fopen("list-logs.php", "w"); ... // traitement ... fclose($myfile);
Super ! Merci beaucoup ça fonctionne ! mais j'ai une dernière petite question, est ce que si je met mes
$password1=63a9f0ea7bb98050796b649e85481845\n$id2=2
au lieu de :
$password1=63a9f0ea7bb98050796b649e85481845
$id2=2
\nentre double cottes, j'aurais mon retour à la ligne ? parce que actuellement ça m'écrit les données comme ceci :
$password1=63a9f0ea7bb98050796b649e85481845\n$id2=2
au lieu de :
$password1=63a9f0ea7bb98050796b649e85481845
$id2=2