A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Data to php

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    15

    Data to php

    Hey Everybody,
    I would like to print the test from a textarea, The php code works but when the page is opened I get error “Undefined index: datatoprint” so the data does not come over to the php page.
    Does someone have un idea?
    p.s. I would like the print.php not to open is their a parameter for it?
    Thanks in advance Dimi

    Code:
    class BulletinBoard
    {
    function onPrint()
    {
    var myData:LoadVars = new LoadVars;
    myData.datatoprint = _root.postMessages.datatoprinttextarea.text;
    myData.send("print.php" , null, "POST");
    }
    }
    PHP Code:
    <?
    $datatoprint = $_POST["datatoprint"];
    $handle = printer_open("HP Deskjet 930c");
    printer_write($handle, $datatoprint);
    printer_set_option($handle, PRINTER_MODE, "raw");
    printer_close($handle);
    ?>
    Last edited by dimiorla; 06-22-2010 at 06:54 AM.

  2. #2
    Happy FK'er TheWaste's Avatar
    Join Date
    Dec 2003
    Location
    Here
    Posts
    779
    Line 3 of the PHP code:
    PHP Code:
    printer_write($handle, $ datatoprint); 
    Should be:
    PHP Code:
    printer_write($handle$datatoprint); 
    You have a space separating the '$' and the variable name (datatoprint)
    "Good lord, you're wasting thousands of dollars worth of Interferon!"
    "... and you're Interferon with our good time!"

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Posts
    15
    Sorry type error, it's not in my print.php
    Last edited by dimiorla; 06-22-2010 at 06:10 AM.

  4. #4
    Happy FK'er TheWaste's Avatar
    Join Date
    Dec 2003
    Location
    Here
    Posts
    779
    Try changing the PHP file to 'GET' instead of 'POST', then try typing the name/value variable into the URL (in your browser) to see if the error comes up.

    For instance:
    http://www.example.com/print.php?dat...intingThisText

    If it works, chances are your variables are not properly sending from Flash.

    If it doesn't work, it means the problem is in your PHP code. Try removing all references to 'printing' (the last three lines). If your code is working now, that means the printer_write line is getting unexpected input (I've never used printer functions in PHP before...)

    What you're doing is the 'process of elimination' to determine the true cause of the problem.

    Undefined index usually means you are trying to use data which has not yet been defined, such as the POST variable you are trying to recieve. Since POST isn't as visible as GET, you may possibly not even be sending the variable.

    Let me know how that goes.
    "Good lord, you're wasting thousands of dollars worth of Interferon!"
    "... and you're Interferon with our good time!"

  5. #5
    Junior Member
    Join Date
    Jun 2007
    Posts
    15
    Thank for the tips, they have helped a lot,
    For anyone interested this works without a popup
    Code:
    myData.sendAndLoad("print.php", this, "POST");
    Last edited by dimiorla; 06-22-2010 at 07:49 AM.

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