A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: format variable & passing to PHP

  1. #1
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756

    format variable & passing to PHP

    ok..normally I would be formatting my data/vars BEFORE I send them to PHP
    (adding my text for formatting...for this example.I am ONLY focusing on the ".txt" part for the file name)

    as such:
    Code:
    sendBuild.frameData = "&frameData="+frameData;
    sendBuild.tankData = "&tankData="+tankData;
    sendBuild.newFileName = newFileName+".txt";
    and then in the PHP script..like so:
    PHP Code:
    $newFileName=$_POST["newFileName"];
    $frameData=$_POST["frameData"];
    $tankData=$_POST["tankData"]; 
    and then:
    PHP Code:
    $fp fopen ("$newFileName""w+"); 
    for what file to "CREATE"...


    HOWEVER, I need to know how to format (add the ".txt" suffix) to the "newFileName" var on the PHP side..before it goes the:
    PHP Code:
    $fp fopen ("$newFileName""w+"); 
    line...


    I guess somethign like this:
    PHP Code:
    $newFileName=$_POST["newFileName"+.txt]; 
    Sorry..this is probably easy..but I dont knwo PHP...

    thanks

  2. #2
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    PHP Code:
     $newFileName=$_POST["newFileName"] . ".txt" 
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  3. #3
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    thank you.....I will try this ASAP...

    so I can still continue to use my open command the same?
    PHP Code:
     $fp fopen ("$newFileName""w+"); 
    ..or does that need to be altered as to pass in the ".txt" as well?

    thanks again

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    yes, you can proceed with your code as is. After that bit of code the $newFileName variable now holds the whole file name with the appended extension.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    hmm...I guess that is NOT delivering the outcome backto me the way I want..(basically I want the value of newFileName ....BACK to flash (as their ID#) but without the .txt extention... so goes to PHP as 1234656 (newFileName)..I add the .txt extension... (which everything worked as you said...thanks).. but when I echo it back.. I need to drop the .txt entension.. (if that makes sense)

    so when they come back..they enter 123456 and not 123456.txt

    so can I NOT do what we outlined above..and ONLY add the .txt to the fopen action? still leaving the newFileName value as 123456??


    thanks

  6. #6
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    PHP Code:
    $newFileName=$_POST["newFileName"];
    $temp$newFileName ".txt";
    $fp fopen ("$temp"w+"); 
    So you have to echo back the $newFileName which is unchnaged.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  7. #7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center