How to read from and write to remote data file?

Hi there
I have two variables that I would like to store in a remote data file which can be accessed by my Flash file. It is for a voting system, so the first variable would be a counter that is incremented each time a user votes, and the second would be the total rating. The average rating would then be calculated from these.
How would one store, retrieve, and then update these variables from the data file?
I can create the system within a single Flash file for a single session, but obviously I'd like multiple users opening the file simultaneously to be able to access the data and update it.
I'm using AS2 in CS3. Any help would be appreciated.

Right, I've made significant progress since I started this topic. I now have my Flash and php files set up, and the communication between them is working. I'm having difficulty now retaining my variables in the php and updating them for the next session. The script that I have is as follows:
<?
$totalRating1 += $_POST['latestRating1'];
$ratingCount1 ++;
$averageRating1 = $totalRating1 / $ratingCount1;
echo "&averageRating=$averageRating1";
?>
The first line receives the variable "latestRating1" from the SWF. The new average rating is calculated and returned to the SWF as "averageRating". When I run it, however, the variables are reset each time. The average rating is always the same as the latest rating. How can I retain the variables so that they are updated and available for the next user?
Any advice would be appreciated. I am very new to php, and don't have any experience with other scripting languages. I'm using ActionScript2.

Similar Messages

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • How to read the and Write the PDF file give me the solution

    Hi all,
    How to read the and Write the PDF file give me the solution
    My coding is
    import java.io.File;
    import com.asprise.util.pdf.PDFImageWriter;
    import com.asprise.util.pdf.PDFReader;
    import java.io.*;
    import java.io.FileOutputStream;
    public class example {
    // public example() {
         public static void main(String a[])
              try
              PDFReader reader = new PDFReader(new File("C:\\AsprisePDF-DevGuide.pdf"));
                   reader.open(); // open the file.
                   int pages = reader.getNumberOfPages();
                   for(int i=0; i < pages; i++) {
                   String text = reader.extractTextFromPage(i);
                   System.out.println("Page " + i + ": " + text);
    // perform other operations on pages.
    PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("c:\\new11.pdf"));
                   writer.open();
                   writer.addImage("C:\\sam.doc");
                   writer.close();
                   System.out.println("DONE.");
    reader.close();
              catch(Exception e){System.out.println("error:"+e);
              e.printStackTrace();
    I get the pdf content then it returns the string value but ther is no option to write the string to PDF, and we only add a image file to PDF,but i want to know how to wrote the string value to PDF file,
    Please give response immtly
    i am waiting for your reply.
    thanks,
    Suresh.G

    I have some question flow
    How library to use this code.
    I try runing but have not libary.
    Please send me it'library
    Thank you very much!

  • How to read a specific line of a .dat file?

    can we read a specific line of a .dat file, if so, how?
    i have this .dat files for each customer, which contain their name on the first line, their id on the second line
    and a list of items and an item id between each item.
    John Doe
    455689
    milk
    1
    orange
    9
    Here is what I am trying to do, please correct me
    //list out .dat file in dir
    File customer_dir = new File ("Customer")
    if (customer_dir.isDirectory())
    String[] listofdat=dir.list();
    for (int i=0;i<listofdat.length();i++)
    Scanner dat_read = new Scanner (new File listfodat);
    dat_read.nextLine();
    if (dat_read.nextLine().equals("455689")) <--is this okay?

    bibiancheng wrote:
    would you please explain to me what
    String[] tokens = line.trim().split("\\s*,\\s*")"\\s*,\\s*" is a regex where \\s means whitespace and the * means "any number of".
    so \\s* means that it will grab all the whitespace if there is any.
    trim() removes white space from the beginning and end of the string.
    dont put a comma in the name.
    spaces allowed: "jane doe, 12-14-09, 428438, 6, 388473, 7, 187374, 3"
    it was just a recommendation. breaking it into separate lines would be fine.

  • How to read from a certain location is a file?

    hi! i am new to programing and i have a problems abt reading from a file. i have write the following to a file using FmtFile :
    10 (a numbers)
    name,phone,product (some strings)
    9 (a numbers)
    when i user ScanFile to read the second number(9 in the above example), i got a wrong value. the command i use is:
    ScanFile (filehandle, "%d", &number1);
    ScanFile (filehandle, "%s[t44]%s[t44]%s",name, phone product);
    ScanFile (filehandle, "%d", &number2);
    number1 and number 2 are integers and name, phone and product are char arrays.
    can anyone tell me where have i gone wrong? or maybe someone can tell me how can i read the 2nd number without reading the 1st number
    and the strings.

    Let's look at your file: if I correctly interpret your question, one row in it should like like this:
    10,name,phone,product,9
    In this case you could use the following formatting string to read all data from the string:
    "%d[x]%s[xt44]%s[xt44]%s[xt44]%d"
    [x] means to discard terminator, in order to read from strings, for example, "name" and not "name,". It's important in this case to put ALL field separators.
    Maybe your problem is that in the file you don't have separators between strings and numbers: in this case the last "%s" should read the '9' inside the last string and the subsequent "%d" matches with incorrect area in the file (end-of-line or next row).
    Hope this help
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How do i create and write to an xml file?

    I know there are methods to create nodes and such but I am not at all familiar with xml. Isn't an easier way just to use the File class to create the file and use the write method to write to the xml file? Thank you.

    tsith wrote:
    <replies>
    <reply>
    <sentence>
    <pronoun>It</pronoun>
    <verb>is</verb>
    </sentence>
    </reply>
    </replies>
    Piddle! Try this: open up Microsoft Word, write "Hello, world!" and save it as XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <?mso-application progid="Word.Document"?>
    <w:wordDocument
        xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
        xmlns:v="urn:schemas-microsoft-com:vml"
        xmlns:w10="urn:schemas-microsoft-com:office:word"
        xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
        xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
        xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
        xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2"
        w:macrosPresent="no"
        w:embeddedObjPresent="no"
        w:ocxPresent="no"
        xml:space="preserve">
        <w:ignoreElements w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2"/>
        <o:DocumentProperties>
            <o:Title>Hello, world</o:Title>
            <o:Author>BDLH</o:Author>
            <o:LastAuthor>BDLH</o:LastAuthor>
            <o:Revision>1</o:Revision>
            <o:TotalTime>0</o:TotalTime>
            <o:Created>2008-09-19T17:37:00Z</o:Created>
            <o:LastSaved>2008-09-19T17:37:00Z</o:LastSaved>
            <o:Pages>1</o:Pages>
            <o:Words>2</o:Words>
            <o:Characters>12</o:Characters>
            <o:Company>Weight Watchers</o:Company>
            <o:Lines>1</o:Lines>
            <o:Paragraphs>1</o:Paragraphs>
            <o:CharactersWithSpaces>13</o:CharactersWithSpaces>
            <o:Version>11.0000</o:Version>
        </o:DocumentProperties>
        <w:fonts>
            <w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/>
        </w:fonts>
        <w:styles>
            <w:versionOfBuiltInStylenames w:val="4"/>
            <w:latentStyles w:defLockedState="off" w:latentStyleCount="156"/>
            <w:style w:type="paragraph" w:default="on" w:styleId="Normal">
                <w:name w:val="Normal"/>
                <w:rPr>
                    <wx:font wx:val="Times New Roman"/>
                    <w:sz w:val="24"/>
                    <w:sz-cs w:val="24"/>
                    <w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/>
                </w:rPr>
            </w:style>
            <w:style w:type="character" w:default="on" w:styleId="DefaultParagraphFont">
                <w:name w:val="Default Paragraph Font"/>
                <w:semiHidden/>
            </w:style>
            <w:style w:type="table" w:default="on" w:styleId="TableNormal">
                <w:name w:val="Normal Table"/><wx:uiName wx:val="Table Normal"/>
                <w:semiHidden/>
                <w:rPr>
                    <wx:font wx:val="Times New Roman"/>
                </w:rPr>
                <w:tblPr>
                    <w:tblInd w:w="0" w:type="dxa"/>
                    <w:tblCellMar>
                        <w:top w:w="0" w:type="dxa"/>
                        <w:left w:w="108" w:type="dxa"/>
                        <w:bottom w:w="0" w:type="dxa"/>
                        <w:right w:w="108" w:type="dxa"/>
                    </w:tblCellMar>
                </w:tblPr>
            </w:style>
            <w:style w:type="list" w:default="on" w:styleId="NoList">
                <w:name w:val="No List"/>
                <w:semiHidden/>
            </w:style>
        </w:styles>
        <w:docPr>
            <w:view w:val="print"/>
            <w:zoom w:percent="100"/>
            <w:doNotEmbedSystemFonts/>
            <w:proofState w:spelling="clean" w:grammar="clean"/>
            <w:attachedTemplate w:val=""/>
            <w:defaultTabStop w:val="720"/>
            <w:punctuationKerning/>
            <w:characterSpacingControl w:val="DontCompress"/>
            <w:optimizeForBrowser/>
            <w:validateAgainstSchema/>
            <w:saveInvalidXML w:val="off"/>
            <w:ignoreMixedContent w:val="off"/>
            <w:alwaysShowPlaceholderText w:val="off"/>
            <w:compat>
                <w:breakWrappedTables/>
                <w:snapToGridInCell/>
                <w:wrapTextWithPunct/>
                <w:useAsianBreakRules/>
                <w:dontGrowAutofit/>
            </w:compat>
            <wsp:rsids>
                <wsp:rsidRoot wsp:val="0077226E"/>
                <wsp:rsid wsp:val="0077226E"/>
            </wsp:rsids>
        </w:docPr>
        <w:body>
            <wx:sect>
                <w:p wsp:rsidR="0077226E" wsp:rsidRDefault="0077226E">
                    <w:r>
                        <w:t>Hello, world!</w:t>
                    </w:r>
                </w:p>
                <w:sectPr wsp:rsidR="0077226E">
                    <w:pgSz w:w="12240" w:h="15840"/>
                    <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="708" w:footer="708" w:gutter="0"/>
                    <w:cols w:space="708"/>
                    <w:docGrid w:line-pitch="360"/>
                </w:sectPr>
            </wx:sect>
        </w:body>
    </w:wordDocument>

  • Using an array to read from and write to files

    my problem is, I do not know how to do this program, it's like an inventory warehouse program that uses an array to store the items, then I have to use a keyboard input to run through the program the first time, using a write method to save the file, and a read method to go through the program a second time and resave it to a different file with the write method, I've asked countless times for help, but the instructor just won't help, so I was hoping I could get some help here, and if I don't get this done, I'm going to end up failing the class.
    also, the requirements are listed here as well, so it can be better understood.
    Write a program that:
    1. allows the user to choose whether the inventory data comes from a file or from the keyboard
    2. allows for up to 20 inventory items
    3. if the data comes from the keyboard, asks for all inventory information (item name, number in stock,
    initial warehouse, and value of one item)
    4. if the data comes from a file, displays the inventory information for the item.
    5. for each item, asks the user how many items to add or delete from inventory
    6. determines whether an item must be moved to a different warehouse and changes the location if
    necessary (note, it may be necessary to move an item to a smaller warehouse)
    7. once all inventory changes have been made, for each warehouse displays the items in the warehouse, the
    total number of items in the warehouse, and the total value of the items in the warehouse.
    8. once all inventory changes have been made, stores the item information in a file (which can be used for
    the next program run)
    9. asks the user for the names of the input file (if data is coming from a file) and the output file (always).
    p.s. I can post the source code for it if it's required for the help.
    Thanks,
    Xandler

    my specific question is how I would go about using the scanner utility to tell it to input from the file or keyboard, if from keyboard it's manually item information is done manually, if from file it asks the user for the file name and the user selects it, then it saves it to a file, can't really post what I've tried because that's the problem, I don't know how to go about doing it and the instructor won't help me, I know though that it requires a file read method for the 2nd run, and a keyboard input for the first and a write for the saving of the file(s).
    Thanks,
    Xandler

  • Read and write excel sheet data from uploded file in sharepoint site programmatically 2013

    hi team,
    I am working on sharepoint 2013.I want to read and write data in excel sheet (micrsoft excel) from stored file in shrepoint docoumnt library .please suggest me
    vijay

    Hi
    Vijay,
    check those links
    http://www.sharepointwithattitude.com/archives/61
    https://social.technet.microsoft.com/Forums/en-US/e760051b-a92f-473c-9ec9-0f0c36c99e40/read-and-write-excel-sheet-data-from-uploded-file-in-sharepoint-site-programmatically-2013?forum=sharepointdevelopment
    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation. Please remember to mark the reply as answer if it helps.

  • Managed Metadata (Failed to read from or write to database. Refresh and try again. If the problem persists, please contact the administrator)

    When creating a new site column of the managed meta data type in SharePoint2010, and you select "customize your term set", you are presented with one of the following errors:
    - This operation cannot be completed. The term store may be unavailable.
    - Failed to read from or write to database. Refresh and try again. If the problem persists, please contact the administrator

    Hi,
    I have been facing the same issue, however managed to resolve it.
    This is due to the uncommitted statements. From Powershell try running the following script
    #Connect to Central Admin, Replace the url with the environment specific URL
    $taxonomySite = get-SPSite http://centraladmin:40000
    #Connect to Term Store in the Managed Metadata Service Application, Ensure you put the right Metadate service application name
    $taxonomySession = Get-SPTaxonomySession -site $taxonomySite
    $termStore = $taxonomySession.TermStores["Managed Metadata Service"]
    write-host "Connection made with term store -"$termStore.Name
    #Connect to the Group and Term Set
    $termStore.RollbackAll()
    Hope it would help

  • How to read each and every word from a string.

    Hi all,
       I have a string which is having many label numbers. if the string is lv_str, its value is like, 11111111111111##22222222222222##3333333333333.
    I need to move the values alone into internal table. each value should be updated as a single row into one internal table. How to read each and every word of the string and move to an internal table.
    the internal table should be like this.
    11111111111111
    22222222222222
    3333333333333
    Can any one give me a suggestion in this regard.
    POINTS PROMISED.
    Regards,
    Buvana

    Hi,
    If you know the format and length of the data
    Use split at '#' so that you will get the individual values.
    Thean append it to internal table.
    Reward iof helpful.

  • "Can't read from or write to disk...." iPod error

    I recently switched from my old PowerBook G4 (running Leopard 10.5.2) to a newer MacBook Pro (running Leopard 10.5.5). I migrated my account and permissions from the PB to the MacBook Pro, and everything is working just fine except for iTunes (version 8.0.2) and my older 160 GB iPod Classic (running 1.1.2).
    NOTE: THE VERSION OF iTunes ON THE PB WAS VERSION 8.0.1.
    Since the migration, I've been getting this "can't read from or write to disk..." error whenever I attempt to sync my iPod to iTunes. Previously, I'd never had any problems. I have tried to restore the iPod using iTunes - didn't work. I have tried different USB to dock connector cables - didn't work. I have even tried completely re-formatting the iPod using Disk Utility - didn't work. Everytime I begin syncing the iPod, it starts out just fine. At varying degrees of completion it ALWAYS fails with the same error.
    I had an idea. I tried syncing the iPod to a different computer - my G5 4 x 2.5 GHz (running Leopard 10.5.5) with iTunes (version 8.0.2). I still got the same error. I haven't dropped it, submerged it in water or done anything to it that would otherwise compromise its functionality. So, I'm at a loss.
    PLEASE! PLEASE! PLEASE!
    Does anyone have any other suggestions? - OTHER THAN BUYING A NEW IPOD

    UPDATE:
    OK, after the visit to my Genius Bar; I thought of a variable that wasn't previously considered. Because their transfer of media was successful without the slightest hitch, I had to figure out something else.
    Everytime I had tried to sync the iPod with my various Macs, I was using the same process. Since all of my music and movies "live" on an external 500 GB drive, I was attempting to use that same drive whenever I would try to sync. It occurred to me that possibly the failing was in the drive and not the iPod.
    I have part of that library on a Power Mac G4 867 DP (running 10.4.9). I updated the iTunes on that machine to 8.0.2, connected the iPod and made a successful transfer of a large amount of media!
    My only problem now is that I can't figure out how to get the 500 GB drive to stop hanging on transfer and update of my Genius information. The drive just completely stalls and I get the spinning wheel from iTunes and the application ceases to respond. When I force quit iTunes, the drive recovers fine. I don't have any problems transferring data to and from it and Disk Utility reports that the drive is healthy.
    I have tried re-installing iTunes on all affected Macs - didn't help. I believe my problem may exist in the iTunes Library file or in the associated .xml document. My only concern is that if I do a completely fresh install of iTunes where those files would be re-created, I would lose all of my play and ratings data as well as the information about when my files were added. On a related note, when playing the music from this drive through iTunes. I don't have any issues at all.
    ANY SUGGESTIONS?

  • How to read from 4 serial ports

    Hi
    Does anyone know how to read from 4 COM ports with only 2 interupts? I can
    manage it by using Close serial driver.vi, however this makes the amount of
    allocated memory by Labview increase throughout my experiment and thereby
    slows down the computer. I use Labview 4.0.1 on Win95.
    Regards
    Frede Lei

    Hi,
    Thanks for the reply however I could able to write the PCR to read one variable without wagetype. My question is, I have 6 variables in VAR table and now I want to read all the variable and based on the variable I need to create the 6 wagetype each for each variable.
    I know to create the wagetype with one variable.
    ZSSB CCE : restore 7SSB wage types paid separately in RT       
            AMT=& VSSB Set                                         
            AMT?0      Comparison                                  
                ADDWTI7SSB IT   Input table                        
              =                                                    
    However, how I could create the only 1 PCR for 6 variable?
    regards,
    Saurabh Garg

  • I used time machine to restore on a formatted MAC. Now the HDD space has reduced by 100GB but I cannot see any of the files. How do I find and delete those 100GB data from the HDD?

    I used time machine to restore on a formatted MAC. Now the HDD space has reduced by 100GB but I cannot see any of the files. How do I find and delete those 100GB data from the HDD?

    dglenn9000 wrote:
    I created a new user account just to see if it was my user Library or if there was something wrong with my system. And the new user account is doing most of the same things so I will need to do a full restore anyway.
    Not necessarily. I'd suggest downloading and installing the "combo" update. That's a combination (thus the clever name) of all the updates to Leopard since it was first released, so installing it should fix anything that's gone wrong since then, such as with one of the normal "point" updates. Info and download available at: http://support.apple.com/downloads/MacOS_X_10_5_8_ComboUpdate Be sure to do a +Repair Permissions+ via Disk Utility (in your Applications/Utilities folder) afterwards.

  • How to read from text file?

    I would like to read data (frequencies) already written in a text file. I will need read these frequencies one at a time to set the function generator (as part of my data acquisition application), acquire data that is in turn written to a file and then go back and read the next frequency from the file to repeat the process again. I also have another idea of doing the same, which is read all the frequencies from the text file and populate a table and a frequency value is picked from the table each time to go through the process mentioned above.
    Can anyone suggest the following: (1) How to read from a text file, (2) What could be the most efficient way of solving my above problem.
    I am a new LabVIEW user and any help will be appreciated.

    Hi Research,
    Depending on the format of the data file, there are a few options for reading it.  If it is tab delimited, you may want to use the Read from SpreadSheet File VI which will read the file into an Array.  You can then use the Index Array VI to pull out individual entries.  If the files is ASCII but not tab delimited, you could use the regular Open File and Read File VIs.  You can either read the file out piece by piece, or read the entire file into a string and then use the Match Pattern VI to parse out the different elements (there are actually many ways to do this - check out the Strings subpalette). 
    Since you're new to LabVIEW, you may want to check out these resources:
    Three Hour Introduction to LabVIEW
    Six Hour Introduction to LabVIEW
    Getting Started with LabVIEW
    I hope this helps!  Let us know if you have more questions,
    Megan B.
    National Instruments

  • Zen - Can't Read from or Write to Your Pla

    I recently bought a Creative Zen and had no problems with the software until recently one day when I was trying to work with a playlist, it said it could not read from or write to my player. I tried a different computer with a different operating system, installed the playlist manager disk on that computer, and got the same result.
    Additionally, when I try to record something, the player freezes up. However, the big issue for me is not being able to manage my playlists at all. I can still download books and tunes and get updates from Creative, so that's not the problem.
    Any help? I looked in the FAQ for this, but the link is broken.

    Try the instructions in this article.
    (24952)

Maybe you are looking for

  • Dreamweaver MX - troubles with a pop-up menu/navbar combo

    Hi all, I'm attempting to create a 4-button navigation bar, where three of the buttons produce a popup menu with links to other pages within the site onMouseOver. The navbar itself works great, but I put all of that in a template, which of course is

  • Need Urgent help on the HR ABAP

    Hi Gurus;               I am new to the HR ABAP, i need some material so that i can build up my concepts in this area. Thanks

  • Asset Revaluation: Depreciation calculation not hiting revaluation accounts

    Dear All, I have to revaluate assets. I have done the configuration as follows: 1. Assignment of Balance sheet and Depreciation accounts for revaluation. 2. Configured depreciation key so that it will calculate the depreciation on the replacement val

  • How to remove the 0 that is added to the formula result

    Hi,        I have a formula field. i placed the formula field in the group footer. zero (0) is added to the formula result. if the formula result is 8 then i am getting 0.00 and 8 as data when i select the browse field data of that field . how to rem

  • Please HELP! I am Losing Apps systematically!!

    This is a bit strange. I have used Macs in one form or another for the last 15 years. I am familiar with them. I have never encountered this problem...or heard of it. 1) About a month ago Safari randomly stopped working. By that, I mean when I try to