Search the Community
Showing results for tags 'fopen'.
-
Hello. I am currently editing my register.php file, which creates the user's account, but also at the same time makes a new file - their profile page. Here is the function: // Create profile page. $handle = fopen($username.".php", 'w'); $pageContent = ""; function createProfile() { fwrite($handle, $pageContent); } createProfile(); This function works, but not when I put this code inside -> https://pastebin.com/9j3rR12v. I have tried to swap all of the " for ' but it doesn't work. What happens is the register.php page does not load at all. It says there is an error. However, it loads the register.php page when I put: // Create profile page. $profileContents = include (profileContents.txt); $handle = fopen($username.".php", 'w'); $pageContent = "<!DOCTYPE html> <head><title>The title has changed.</title></head>"; function createProfile() { fwrite($handle, $profileContents); } createProfile(); When I then make an account, it creates the file, but the content doesn't go inside. A link to the code I would like to be displayed can be found here (compressed version): https://pastebin.com/9j3rR12v If you are able to help me out, it would mean the world. Many thanks. Emergency email: whunter@voltboxgaming.co.uk
-
<?php if (empty($count)) { $count=''; } if ($count == '') { $count ='1'; } else { $count++ ; } echo $count; echo '<br>'; ?> My goal is to make a script that increments $count ever time someone downloads the page. Can this be done without 'storing' the $count value? Or should I create a script with fwrite/fopen or $_SESSION?
-
What is the difference between using the directory functions to change the directory and opening file as opposed to just opening the file straight? I am not sure if you can open a file in a different directory by using the directory function or not, so correct me if it is not possible. chdir("info/");$fileName="info.txt";$file=fopen($fileName,"r+"); VS $directory="info/";$fileName="info.txt";$file=fopen($directory.$fileName,"r+"); If we use the first, how do we change back to the previous directory? If both is possible, which is the better method? Outside of opening files, which is better? Using strings or directory functions?
-
I am developing the file locally with LAMPP and my source file is like this: <?php echo "The server is working"; ?><?php$file=fopen("file.txt", "r") or exit("Unable to open file!");?> In the same directory is a text file named file.txt and it has a line on text in it. The output however is only The server is working. Nothing else.