# Help with writing to text file: basic php may be

**URL:** <https://forum.kirupa.com/t/help-with-writing-to-text-file-basic-php-may-be/223260>\
**Category:** flash\
**Created:** [April 20, 2007, 5:29pm UTC](https://forum.kirupa.com/t/help-with-writing-to-text-file-basic-php-may-be/223260 "2007-04-20T17:29:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceblueflame](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@iceblueflame](https://forum.kirupa.com/u/iceblueflame)\
**Post date:** [April 20, 2007, 5:29pm UTC](https://forum.kirupa.com/t/help-with-writing-to-text-file-basic-php-may-be/223260/1 "2007-04-20T17:29:22Z")

</div>

I’m trying to write some text to a text file. Actually, i retrieved the text from the file simply without using any PHP, so i thought there might be a way to write back to it without PHP too. Is there?? i couldn’t find any through flash help files though…

Anyways, so i started trying to use PHP for it. I wrote some code so that it took some text from a dynamic text box on stage, and would write it into a text file in a folder inside the one which contains the swf and the php file.

here is the code:  
Actionscript:

```auto

//Inside the button i press to send the code:
 
on(release)
{
 var data_lv:LoadVars = new LoadVars();
 var send_lv:LoadVars = new LoadVars();
 data_lv.notes = _root.notesCont.nt.inside.notepad.notes_txt.text;
 
//i know thats a lot of nesting of movieclips, but the path is fine
//i checked.
 
 send_lv.sendAndLoad("notesPhp.php",data_lv);
}
 

```

here’s the php code in notesPhp.php file located in the same folder.

```auto

<?php
$nValue = $_POST['notes'];
$filename = "/userName/myNotes.txt";
$handle = fopen($filename, "w"); 
fwrite($handle, "$nValue");
fclose($handle);
?>

```

But the file myNotes doesnt get written… Its inside the userName directory. Where is the mistake? i am very new to php so i have no clue what might be going wrong there. i might be writing the path incorrectly or anything  
Also, i dont really get the hang of sendAndLoad function. As in, why i need to use the data\_lv object necessarily.  
So how exactly DO i send the text from a dynamic text box to a file??  
Is there some way around php for this too??  
Whats wrong with this code?
