Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP text writing issues.

Posted on 2004-11-02
13
Medium Priority
?
210 Views
Last Modified: 2010-04-03
Hey,

trying to get php to work for me(still), and it doesn't seem to want to do it. i found this,

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20932516.html?query=PHP%2C+text+writing%2C+fwrite&topics=116

and pasted the suggestion in just to see if i could get something to pop out for me. when i click the button, all that happens is that a new browser window pops open with the code in it, no text file happens. obviously what i would like to have happen is NO browser window pop open, and a text file get born from the process, or overwritten.

thanks.
0
Comment
Question by:AlexSilverman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 

Author Comment

by:AlexSilverman
ID: 12476114
Okay, so i just found a thing saying the PHP won't run locally... is there a way to write out a txt file locally?
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12476181
The php file is ok, what you need is:


myLoadVars = new LoadVars();
myLoadVars.variableOne = "This is the contents of the first variable";
myLoadVars.variableTwo = "This is the contents of the second variable";
myLoadVars.sendAndLoad("textfileMaker.php", myLoadVars, "POST");


notice "sendAndLoad" instead of "send".

It works if:

- server supports php
- you have write permission on that folder

If you are testing it locally, you should use:

myLoadVars = new LoadVars();
myLoadVars.variableOne = "This is the contents of the first variable";
myLoadVars.variableTwo = "This is the contents of the second variable";
myLoadVars.sendAndLoad("http://localhost/foldername/textfileMaker.php", myLoadVars, "POST");
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12476189
ehehe, I was answering..
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Accepted Solution

by:
negatyve earned 2000 total points
ID: 12476200
Oh, if you're planning to save a file on the client machine, you should think about using SharedObject..
0
 

Author Comment

by:AlexSilverman
ID: 12476409
just was looking into them.

how do you use a shared object to write variables to?
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12476471
// gets the saved cookie: if it's missing, creates it
var so = SharedObject.getLocal("cookie_name");
// if you saved "your_property" in the inner data object
if(so.data.your_property != undefined){
      // trace it
      trace(so.data.your_property);
} else {
      // if not, then save it
      so.data.your_property = your_value;
      // write the cookie
      so.flush();
}

more info: http://www.macromedia.com/support/flash/action_scripts/local_shared_object/index.html
0
 

Author Comment

by:AlexSilverman
ID: 12477193
I have this in a button :

on (press) {
      var so = SharedObjects.getLocal("User_Info");
      so.data.home_phone = _level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text;
      so.data.work_phone = _level1.BENCB.Main.BEN_MAIN.Options.WorkPhone_txt.text;
      so.data.cell_phone = _level1.BENCB.Main.BEN_MAIN.Options.CellPhone_txt.text;
      so.data.pager_number = _level1.BENCB.Main.BEN_MAIN.Options.PagerNumber_txt.text;
      so.data.email_address = _level1.BENCB.Main.BEN_MAIN.Options.EmailAddress_txt.text;
      so.flush();
}

And then this trying to retrieve :

function GetUserInfo() {
    trace("hit Get User Info");
    var so = SharedObjects.getLocal("User_Info");
    if (so.data.home_phone != undefined) {
      trace("defined");
      _level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text = so.data.home_phone;
      _level1.BENCB.Main.BEN_MAIN.Options.WorkPhone_txt.text = so.data.work_phone;
      _level1.BENCB.Main.BEN_MAIN.Options.CellPhone_txt.text = so.data.cell_phone;
      _level1.BENCB.Main.BEN_MAIN.Options.PagerNumber_txt.text = so.data.pager_number;
      _level1.BENCB.Main.BEN_MAIN.Options.EmailAddress_txt.text = so.data.email_address;
    } else {
                trace("not defined");
      _level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text = "###-###-####";
      _level1.BENCB.Main.BEN_MAIN.Options.WorkPhone_txt.text ="###-###-####";
      _level1.BENCB.Main.BEN_MAIN.Options.CellPhone_txt.text = "###-###-####";
      _level1.BENCB.Main.BEN_MAIN.Options.PagerNumber_txt.text = "###-###-####";
      _level1.BENCB.Main.BEN_MAIN.Options.EmailAddress_txt.text = "http://www.hotmail.com";
    }
}

it keeps popping up as undefined, even after i run through the first script to try and initialize the object's data for future use. is there something wrong with this?
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12477343
Try:

on (press) {
     var so = SharedObjects.getLocal("User_Info");
     so.data.home_phone = _level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text;
     so.data.work_phone = _level1.BENCB.Main.BEN_MAIN.Options.WorkPhone_txt.text;
     so.data.cell_phone = _level1.BENCB.Main.BEN_MAIN.Options.CellPhone_txt.text;
     so.data.pager_number = _level1.BENCB.Main.BEN_MAIN.Options.PagerNumber_txt.text;
     so.data.email_address = _level1.BENCB.Main.BEN_MAIN.Options.EmailAddress_txt.text;
     // what does this trace ?
     trace(so.data.home_phone);
     so.flush();
}
0
 

Author Comment

by:AlexSilverman
ID: 12477432
it is popping out as undefined... but the value of the text field is coming through fine in a trace next to it.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12477599
and this:

on (press) {
     var so = SharedObjects.getLocal("User_Info");
     so.data.home_phone = _level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text;
     so.data.work_phone = _level1.BENCB.Main.BEN_MAIN.Options.WorkPhone_txt.text;
     so.data.cell_phone = _level1.BENCB.Main.BEN_MAIN.Options.CellPhone_txt.text;
     so.data.pager_number = _level1.BENCB.Main.BEN_MAIN.Options.PagerNumber_txt.text;
     so.data.email_address = _level1.BENCB.Main.BEN_MAIN.Options.EmailAddress_txt.text;
     // what does this trace ?
     trace(_level1.BENCB.Main.BEN_MAIN.Options.HomePhone_txt.text);
     so.flush();
}
0
 

Author Comment

by:AlexSilverman
ID: 12477638
it's tracing out what is thare, that what i meant when i said the text field was coming through fine.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 12477707
Now I see, it's:

var so = SharedObject.getLocal("cookie_name");

not

var so = SharedObjects.getLocal("cookie_name");
0
 

Author Comment

by:AlexSilverman
ID: 12477880
sweet, thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question