Code: Select all
if (isset( $_POST ))
$postArray = &$_POST ;
else
$postArray = &$HTTP_POST_VARS;
$user = $postArray[theuser];
$log = $postArray[thelog];
$back = $postArray[theback];
$fname = $user;
$arr = array(
"New XML Data"
);
$nfile = fopen($fname, "w");
foreach($arr as $x)
{
fwrite($nfile, $x);
}
fclose($nfile);
'Warning: fwrite(): supplied argument is not a valid stream resource in edit.php on line 69'
AND
'Warning: fclose(): supplied argument is not a valid stream resource in edit.php on line 71'
Line 69 refers to 'fwrite($nfile, $x);' and line 71 refers to 'fclose($nfile);'.
I tried to change '$fname = $user;' to '$fname = array($user);', but that returned the error:
'Warning: fopen() expects parameter 1 to be string, array given in edit.php on line 66'
Line 66 refers to '$nfile = fopen($fname, "w");'.
At first, '$fname' was '$fname = "example.xml";' which worked perfectly.
I don't have much knowledge in PHP and therefore have no idea on how i can convert the variable $user into a string, which i think is required.
Any kind of help is much appreciated.