problem mit fopen

Fragen zu allen Themen rund ums Programmieren außerhalb von phpBB können hier gestellt werden - auch zu anderen Programmiersprachen oder Software wie Webservern und Editoren.
Antworten
gfc

problem mit fopen

Beitrag von gfc »

kann mir mal einer helfen? Was is hier falsch:

Code: Alles auswählen

<?php

$EggFile = "./partner/parkrocker.txt"; // Name (evtl. inkl Pfad) des eggdrop-Files... z.b. /usr/local/eggy/eggy.txt

 $fp = fopen("$EggFile", "r");
 $count = 0;
 while (!feof($fp)) {
  $curr = trim(fgets($fp, 4096));
  $curr = ltrim($curr, '~&@%+');
  if ($curr != '') {
   if (strlen($curr) > 16) {
    $chatterz[$count++] = substr($curr,0,12).'...';
   } else {
    $chatterz[$count++] = $curr;
   }
  }
 
 fclose($fp);
 $anzahl = count($chatterz);
 if ($anzahl == 0) {
  srand((float) microtime() * 10000000);
  $input = array ('Niemand im Chat :(', 'Chat ist leer', 'Keine Chatterz :(');
  $rand_key = array_rand($input);
  $out = $input[$rand_key];
 } else if ($anzahl == 1) {
  $out = 'Eine Person im Chat:<br><b>'.$chatterz[0].'</b>';
 } else {
  $out = $anzahl.' Uniboarder im Chat:<br><b>';
  natcasesort($chatterz);
  $out .= implode(', ', $chatterz).'</b>';
 }
} else {
 $out = '<!-- Kann das Eggdrop-Chatterlist-File nicht finden!!! Bitte Konfiguration nochmals überprüfen... -->';
}

?>
Fehlermeldung: Parse error: parse error, unexpected T_VARIABLE in *gekürzt*/test.php on line 5
Benutzeravatar
Mister_X
Ehemaliges Teammitglied
Beiträge: 7102
Registriert: 24.05.2001 02:00
Wohnort: Augsburg

Beitrag von Mister_X »

also mir springt da jetzt erstmal nur das doppelte else am Schluss ins Auge...
PhilippK
Vorstand
Vorstand
Beiträge: 14662
Registriert: 13.08.2002 14:10
Wohnort: Stuttgart
Kontaktdaten:

Beitrag von PhilippK »

Nehm mal testweise

Code: Alles auswählen

$EggFile
statt

Code: Alles auswählen

"$EggFile"
- evtl. gibt's damit Probleme.

Gruß, Philipp
Kein Support per PN!
Der Sozialstaat ist [...] eine zivilisatorische Errungenschaft, auf die wir stolz sein können. Aber der Sozialstaat heutiger Prägung hat sich übernommen. Das ist bitter, aber wahr. (Horst Köhler)
Meine Mods
gfc

Beitrag von gfc »

thx, das hab ich jetzt auch gesehen. ursprünglich sah das script eben ein wenig anderst aus nämlich so:

Code: Alles auswählen

$eggy_file = 'unizh.txt'; // Name (evtl. inkl Pfad) des eggdrop-Files... z.b. /usr/local/eggy/eggy.txt
if (file_exists($eggy_file)) {
 $fp = fopen("$eggy_file", "r");
 $count = 0;
 while (!feof($fp)) {
  $curr = trim(fgets($fp, 4096));
  $curr = ltrim($curr, '~&@%+');
  if ($curr != '') {
   if (strlen($curr) > 16) {
    $chatterz[$count++] = substr($curr,0,12).'...';
   } else {
    $chatterz[$count++] = $curr;
   }
  }
 }
 fclose($fp);
 $anzahl = count($chatterz);
 if ($anzahl == 0) {
  srand((float) microtime() * 10000000);
  $input = array ('Niemand im Chat :(', 'Chat ist leer', 'Keine Chatterz :(');
  $rand_key = array_rand($input);
  $out = $input[$rand_key];
 } else if ($anzahl == 1) {
  $out = 'Eine Person im Chat:<br><b>'.$chatterz[0].'</b>';
 } else {
  $out = $anzahl.' Uniboarder im Chat:<br><b>';
  natcasesort($chatterz);
  $out .= implode(', ', $chatterz).'</b>';
 }
} else {
 $out = '<!-- Kann das Eggdrop-Chatterlist-File nicht finden!!! Bitte Konfiguration nochmals überprüfen... -->';
}
gehen aber beide varianten nicht. das fopen will und will nicht..
Antworten

Zurück zu „Coding & Technik“