# Writing to a txt with php

**URL:** <https://forum.kirupa.com/t/writing-to-a-txt-with-php/163119>\
**Category:** Uncategorized\
**Created:** [September 20, 2005, 12:04am UTC](https://forum.kirupa.com/t/writing-to-a-txt-with-php/163119 "2005-09-20T00:04:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigepmest37](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sigepmest37](https://forum.kirupa.com/u/sigepmest37)\
**Post date:** [September 20, 2005, 12:04am UTC](https://forum.kirupa.com/t/writing-to-a-txt-with-php/163119/1 "2005-09-20T00:04:19Z")

</div>

i am using the following php:

```php
 <?php 
$filename ="aboutme.txt"; 
$writeError = false; 
$fileStream; 
if (!$fileStream = fopen($filename,'w')) { 
	$writeError = true; 
} else { 
	if (!fputs($fileStream, stripslashes($stuffToWrite))) { 
		$writeError = true; 
	} else { 
		fclose($fileStream); 
	} 
} 
print "&wroteFile=".$writeError; 
?> 

```

the problem i am having is that it will create the txt file on the server, but it will not write the contents…it just leaves me with an epty aboutme.txt…anybody have a clue?

thanks for your help
