Seite 1 von 1

problem mit fopen

Verfasst: 15.03.2004 00:11
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

Verfasst: 15.03.2004 00:25
von Mister_X
also mir springt da jetzt erstmal nur das doppelte else am Schluss ins Auge...

Verfasst: 15.03.2004 00:28
von PhilippK
Nehm mal testweise

Code: Alles auswählen

$EggFile
statt

Code: Alles auswählen

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

Gruß, Philipp

Verfasst: 15.03.2004 00:30
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..