I have an account system that reads info from a file. These include (in order) username, password, email, bio, reputation. But for some reason (when I load the data with a series of fgets()) It returns the following error:
Warning: fgets() expects parameter 1 to be resource, null given in /home/dsgamesr/public_html/lualessons.x10host.com/userpage.php on line 95.
I made sure that $rep was an item in the text file. The program proceeds but still resets the $rep variable (and saves it as) blank. The code is as follows:
<?php
if (isset($_POST['button1']))
{
$file=fopen("Users/user".$_SESSION['Username'].".txt","r");
$user=trim(fgets($file));
$pass=trim(fgets($file));
$email=trim(fgets($file));
$bio=trim(fgets($file));
$rep=fgets($files);
fclose($file);
echo $rep;
$nfile=fopen("Users/user".$user.".txt","w");
fwrite($nfile,$user."
");
fwrite($nfile,$pass."
");
fwrite($nfile,$email."
");
fwrite($nfile,$_POST['bio']."
");
fwrite($nfile,$rep."
");
echo'Bio succesfully updated';
//echo $user;
}
?>
There is a total of five lines before I submit the new bio and a total of 5 with the final line blank after I submit it.