Forum Moderators: coopster

Message Too Old, No Replies

resource id #2

can't read variable

         

WhosAWhata

4:00 am on May 18, 2004 (gmt 0)

10+ Year Member




<?
$file = $_GET['file'];
if($make && $nfile) {
$a = fopen($nfile,w);
fputs($a,"");
fclose($a);
}
if(($file) && (file_exists($file))) {
if($submit) {
$file=fopen("$file",w);
fputs($file,$text);
fclose($file);
}
$a = file_get_contents("$file");
$html .= "<html><head><title>$file</title></head><body bgcolor=black text=lime><center><h1>$file</h1><hr width=85%>";
$html .= nl2br($a);
$m = ereg_replace("./","",$file);
$html .= "<hr width=85%><form action=$PHP_SELF?file=$m method=post><textarea name=text cols=150 rows=10>$a</textarea><input type=submit name=submit value=submit>";
echo $html;
} else {
$files = glob("./{*.txt}",GLOB_BRACE);
if($files) {
$b=1;
foreach ($files as $f => $v) {
if ($b) { $c = " SELECTED "; } else { $c = ""; }
$html .= "<option value=\"".$v."\"".$c.">".$v."</option>";
}
}
$html2 = "<form action=$PHP_SELF method=post>New: <input type=text name=nfile><input type=submit name=make value=go!></form>";
?>
<html><head><bgcolor=black text=lime><form action=<?=$PHP_SELF?> method=get><select name=file><?=$html?></select><input type=submit name="go" value="Edit/View"></form><br><Br><?=$html2?>
<?
}
?>

for some reason, after submitting, $file becomes Resource ID #2

WHY

coopster

4:55 pm on May 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$file=fopen [php.net]("$file",w);

You are binding a named resource, specified by the filename (first parameter of the fopen function), to a stream.

WhosAWhata

10:12 pm on May 18, 2004 (gmt 0)

10+ Year Member



can'tbelieve i missed that
sorry
didn't have much time to de-bug