# Exporting to a textfile (or any other if better)

**URL:** <https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588>\
**Category:** programming\
**Created:** [December 26, 2003, 5:52am UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588 "2003-12-26T05:52:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riddler](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@Riddler](https://forum.kirupa.com/u/Riddler)\
**Post date:** [December 26, 2003, 5:52am UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/1 "2003-12-26T05:52:56Z")

</div>

Ok I’m trying to make a small thing on a website that will allow the user to update the news themselves… after reading up on it i found that to export a textfile in this way I would have to have a serverside script to execute it for me (PHP in my case)… I did it, but it isnt working… what am i doing wrong? plz help

SOURCES:

[http://jayhayes.no-ip.com/Jay/crap/exporter.zip](http://jayhayes.no-ip.com/Jay/crap/exporter.zip)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:27pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/2 "2003-12-26T18:27:05Z")

</div>

im kind of confused why i havent gotten any help :puzzle:

so i thought maybe you guys didnt want to take the time to download the sources… so here they are…

I have a button in my movie that contains this:  
[AS]loadVariablesNum (“save.php”, 0, “POST”);[/AS]

and then a php file that contains this:

```php

<? php
$test = $_POST["test"];
$filname = './test.txt';
$fp = fopen($filname, 'w');
fputs($fp, "$test");
fclose($fp);
?>

```

im not extremely familiar w/ php so idk what the prob is… help plz 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:29pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/3 "2003-12-26T18:29:20Z")

</div>

it is a holiday, in the US anyway, most people are with family and away from their computers.

patience is a virtue.

it isn’t personal, the right person will answer when they get a chance.

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:35pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/4 "2003-12-26T18:35:25Z")

</div>

hehe i know… i was just trying to help out and save some folks some time 😃 happy holidays! (the birth of Jesus is a world wide holiday ;))

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:37pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/5 "2003-12-26T18:37:42Z")

</div>

> \*Originally posted by Riddler? \*  
> \*\*hehe i know… i was just trying to help out and save some folks some time 😃 happy holidays! (the birth of Jesus is a world wide holiday ;)) \*\*

[s] really?

I hadn’t noticed… [/s]

You were the one wondering, outloud, why your thread hadn’t been answered, so don’t get snippy to me…

Rev

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:39pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/6 "2003-12-26T18:39:18Z")

</div>

haha i have no idea what your problem is, but im sorry if i offended you … lol that really caught me off guard…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:44pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/7 "2003-12-26T18:44:13Z")

</div>

> (the birth of Jesus is a world wide holiday )

wasn’t a smartass comment? you were the one who put the 😉 wink guy next to your obvious statement.

You are not well known here, so how am I supposed to know your intent? You sounded impatient, so I made an attempt to calm your eagerness. You then make a snippy remark with a wink, and now you say it caught you off guard?

BTW - if you want to use a flash footer, it needs to be 300 wide x 60 tall maximum. Just an FYI

Rev

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 6:49pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/8 "2003-12-26T18:49:26Z")

</div>

thanx man for the help… something must be wrong w/ my sytax because the sig still isnt working

and im sorry, i wasnt being sarcastic or smart toward you… sorry you took it that way. i was just being happy, not a butt

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:16pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/9 "2003-12-26T19:16:49Z")

</div>

cool.

I think it is the swf=" thing…

(I’m not really a programmer, more of an animater from way back)

there is a sticky somewhere about this…

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:20pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/10 "2003-12-26T19:20:35Z")

</div>

Adding flash footers  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:21pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/11 "2003-12-26T19:21:20Z")

</div>

thanks claudio…

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:22pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/12 "2003-12-26T19:22:15Z")

</div>

No problem Rev 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:23pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/13 "2003-12-26T19:23:58Z")

</div>

w00t thanx guys!! now for the real problem… hehe

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 7:43pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/14 "2003-12-26T19:43:29Z")

</div>

Vash is the php guy… this may be better in the server side forum.

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 8:21pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/15 "2003-12-26T20:21:06Z")

</div>

I had thought so too after i posted here… is there anyway it can be moved so i dont have to double post?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 8:25pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/16 "2003-12-26T20:25:05Z")

</div>

consider it moved…

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 9:46pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/17 "2003-12-26T21:46:28Z")

</div>

> \*Originally posted by reverendflash \*  
> \*\*consider it moved…

Rev \*\*

this thread isn’t the only thing moved 🙂

[http://kirupa.rastardesigns.com/exporter.zip](http://kirupa.rastardesigns.com/exporter.zip)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 26, 2003, 9:56pm UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/18 "2003-12-26T21:56:46Z")

</div>

Norie… I LOVE YOU :D!!! Thank you sooo much… and also big props for explaining that code too!!! thank you! i will try to remember to show you guys my finished product when im done :D!!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2003, 5:04am UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/19 "2003-12-27T05:04:24Z")

</div>

hey thanx for the awesome help, but after I got to messing w/ it I hit another small problem that my lack on PHP knowledged kept me from fixing… here is my updated file i made to suit me:

```php
<?php
$filename = 'news.txt';
$tag = 'news=';
$somecontent = $_POST['news'];

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    if (!$handle = fopen($filename, 'w')) {
         print "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (!fwrite($handle, $tag)) {
       print "Cannot write to file ($filename)";
        exit;
    }
    
// print "news=$tag";
    
    fclose($handle);

    if (!$handle = fopen($filename, 'a')) {
         print "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (!fwrite($handle, $somecontent)) {
       print "Cannot write to file ($filename)";
        exit;

    print "news=$somecontent";
    
    fclose($handle);
    
}
    
    print "news=$somecontent";
					
} else {
    print "news=The file $filename is not writable";
}
?>

```

my prob is that if i enter something into my text box that has an apostrophe of quotation PHP automatically adds the backslash for the obvious reasons… but this messes me up when I try to use my HTML tags or just apostrophe’s in my lil example thing at [www.jayhayes.no-ip.com/Jay/crap/thingy.html](http://www.jayhayes.no-ip.com/Jay/crap/thingy.html) thanx again guys

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 27, 2003, 7:30am UTC](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588/20 "2003-12-27T07:30:58Z")

</div>

```php
<?php
//return var 'news'
$filename = 'news.txt';
$somecontent = stripslashes($_POST['news']);

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    if (!$handle = fopen($filename, 'w')) {
         print "news=Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (!fwrite($handle, $tag)) {
       print "news=Cannot write to file ($filename)";
        exit;
    }
    
// print "news=$tag";
    
    fclose($handle);

    if (!$handle = fopen($filename, 'a')) {
         print "news=Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (!fwrite($handle, $somecontent)) {
       print "Cannot write to file ($filename)";
        exit;

    print "news=$somecontent";
    
    fclose($handle);
    
}
    
    print "news=$somecontent";
                    
} else {
    print "news=The file $filename is not writable";
}
?>

```

[Next page](https://forum.kirupa.com/t/exporting-to-a-textfile-or-any-other-if-better/38588.md?page=2)
