Casalen Posted September 9, 2006 Share Posted September 9, 2006 Okay, so I'm expanding the user data functions on a script. It now creates a directory for each new user, including a few files. Each of the database files starts with a die command so that it can't be easily read from the browser. After the die command is written the character \n, which should translate into a new line in the text file. So I take a file, open it in notepad++ to see if the data wrote, and find the data written... except that I see \n instead of a new line. All except for one file, base.db.php, which works perfectly. Any suggestions? I don't really need that part, but it's frustrating anyway. I'm pretty tired right now, so forgive me if it's something I should have seen.[code]$new_index_file = fopen("$userdir" . "/index.php", "a"); $new_base_file = fopen("$userdir" . "/base.db.php", "a"); $new_profile_file = fopen("$userdir" . "/profile.db.php", "a"); fwrite($new_base_file, "<?PHP die(\"You cannot access this file.\"); ?>|\n"); fwrite($new_base_file, "$add_time|$reglevel|$regusername|$regpassword|$regnickname|$regemail|$regusergroups|0|0||||\n"); fwrite($new_profile_file, "<?PHP die(\"You cannot access this file.\"); ?>|\n"); fwrite($new_profile_file, "$firstname|$lastname|$birthday|$hidemail|$title|$description|$status|0|0|||\n"); $new_calendar_file = fopen("$userdir" . "/calendar.db.php", "a"); fwrite($new_calendar_file, '<?PHP die("You cannot access this file."); ?>\n');[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20206-n-in-text-database/ Share on other sites More sharing options...
redarrow Posted September 9, 2006 Share Posted September 9, 2006 dosent a \n line need a \n\ Quote Link to comment https://forums.phpfreaks.com/topic/20206-n-in-text-database/#findComment-88873 Share on other sites More sharing options...
wildteen88 Posted September 9, 2006 Share Posted September 9, 2006 The problem is you are using single quotes when writring to calendar.php:[code=php:0]fwrite($new_calendar_file, '<?PHP die("You cannot access this file."); ?>\n');[/code]If you use single quotes. PHP will treat \n as-s (meaning normal text). it will not treat \n as a new line character. The solution is to use double quotes:[code=php:0]fwrite($new_calendar_file, "<?PHP die(\"You cannot access this file.\"); ?>\n");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20206-n-in-text-database/#findComment-88913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.