A Flash Developer Resource Site

Page 4 of 7 FirstFirst 1234567 LastLast
Results 61 to 80 of 126

Thread: PHP not working?

Hybrid View

  1. #1
    imagination through stupidity
    Join Date
    Apr 2001
    Location
    P3X-3113
    Posts
    1,238
    HTTP POST variables: $_POST
    Note: Introduced in 4.1.0. In earlier versions, use $HTTP_POST_VARS.

    An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope.

    This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.

    $HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that $HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)

    If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_POST and $HTTP_POST_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.

    http://us2.php.net/reserved.variables
    Nothing to see here, move along.

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    180

    Musicman to the rescue? :)

    Hi Musicman,
    I hate to bother you but I've been following alot of your sound advice on this board (no pun intended) and have been unsuccesful in accomplishing what I am trying to do.
    I bought a magazine that has a tutorial and a .fla for a php driven flash player. The problem is that the entire code is setup for a dynamic playlist, and in my situation I will only have one song per page. I am sending the variables to Flash like this:
    ...<param name="movie" value="player.swf<?php echo "?mp3_path=$mp3&stitle=$stitle" ?>">...
    and
    ...<embed src="player.swf<?php echo "?mp3_path=$mp3&stitle=$stitle" ?>"...

    What I need to know is how would I change the following code to reflect that? Their code is chuck full of functions for changing to the next track and prev track, etc and it's way over my head. I would like to keep the normal id3 and play type functions but lose all of the multiple track info. If anybody could help on this I would really appreciate it. I got in trouble right from the start because this code tries to call the mp3 path variable from a php file but it doesnt need to because I am assigning it with the above code. The nunomira page says that I can access the variables in Flash with this:

    trace(_level0.mp3_path);

    Do I need to trace the variable or can I just use
    mp3=(_level0.mp3_path); ?

    Here is the raw code that I need to somehow strip down to just a one song script. Thank you VERY MUCH for any advice or help.

    lv = new LoadVars();
    lv.onLoad = function()
    {
    mp3list = new Array();
    var i = 0;
    while (this["file" + i] != undefined)
    {
    mp3list[i] = this["file" + i];
    i++;
    }
    }
    lv.load("getmp3s.php");

    volumeB.stop();

    volumeB.onPress = function()
    {
    this.gotoAndStop(3);
    this.startDrag(false, this._x, 29, this._x, 144);

    volumeB.onMouseMove = function()
    {
    mp3Sound.setVolume(100 - ((this._y - 29) / 115) * 100);
    }
    }

    volumeB.onRelease = volumeB.onReleaseOutside = function()
    {
    this.gotoAndStop(1);
    this.stopDrag();
    }

    function loadTrack(fname)
    {
    mp3Sound = new Sound();
    mp3Sound.loadSound(fname, true);

    mp3Sound.onID3 = function()
    {
    textString = this.id3.track + ". " + this.id3.songname + " (c)" + this.id3.year + " - " + this.id3.artist + " - " + this.id3.album + " ";
    tracktitle.text = textString;
    }

    mp3Sound.onSoundComplete = nextTrack;

    tracktitle.text = fname;
    tracktime.text = "0:00";
    }

    currentTrack = -1;
    function nextTrack()
    {
    clearInterval(playback);
    playback = setInterval(refreshDisplay, 250);

    wrap = 0;
    currentTrack++;
    currentTrack%=mp3list.length;
    loadTrack(mp3list[currentTrack]);
    }

    function prevTrack()
    {
    clearInterval(playback);
    playback = setInterval(refreshDisplay, 250);

    wrap = 0;
    currentTrack--;
    if (currentTrack < 0) currentTrack = mp3list.length-1;
    loadTrack(mp3list[currentTrack]);
    }

    function stopTrack()
    {
    stoppos = mp3Sound.position;
    mp3Sound.stop();
    }

    function resumeTrack()
    {
    if (stoppos == undefined)
    {
    nextTrack();
    }
    else
    mp3Sound.start(stoppos / 1000);
    }

    function rewindTrack()
    {
    pos = mp3Sound.position;
    pos -= 2000;
    if (pos < 0) pos = 0;
    mp3Sound.start(pos / 1000);
    }

    //nextTrack();

    nextTrackButton.onRelease = nextTrack;
    prevTrackButton.onRelease = prevTrack;
    stopButton.onRelease = stopTrack;
    playButton.onRelease = resumeTrack;
    rewindButton.onRelease = rewindTrack;

    progressb.inner._width = 0;

    refreshDisplay = function()
    {
    tracktitle.text = textString.substr(wrap, textString.length) + textString;
    wrap++;
    wrap %= textString.length;

    var pos = Math.floor(mp3Sound.position / 1000);
    sec = (pos % 60).toString();
    min = Math.floor(pos / 60).toString();
    if (sec.length == 1) sec = "0" + sec;

    tracktime.text = min + ":" + sec;
    progressb.inner._width = (mp3Sound.position / mp3Sound.duration) * 250;
    }

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    replacing this code

    lv = new LoadVars();
    lv.onLoad = function()
    {
    mp3list = new Array();
    var i = 0;
    while (this["file" + i] != undefined)
    {
    mp3list[i] = this["file" + i];
    i++;
    }
    }
    lv.load("getmp3s.php");

    by

    mp3list = [_level0.mp3_path];

    should populate the playlist with one song, and hopefully disable next track, randomize, or anything else that makes sense only with multiple songs

    Musicman

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    180
    Before I even try it I want to say thanks alot.
    I'll let you know how it goes.
    Thanks again, hope I can repay the favor someday.

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Posts
    180
    You are the man!!
    Holy cow, what a great idea, I was pulverizing the thing. Its working like a champ except for one tiny thing. When I first loaded the song the id3 info scrolled across the screen. When I go back to the page it just says NAN and doesnt scroll. ?
    I am completely grateful for you getting me this far and wont be crushed if you cant help with that minor bug.

    Hats off, Musicman!

  6. #6
    Junior Member
    Join Date
    Aug 2000
    Location
    Jacksonville Florida
    Posts
    28

    php form

    I just have a simple PHP form and using Flash 5. It submits the info except for the last field - email address. I guess its this different syntax I have seen that causes a problem with just the last part of the script? Any PHP gurus tell me why it submits the info ok but not the email address box on the form inside the flash file?

    PHP -


    <?

    $to = "[email protected]";
    $msg = "$name\n\n";
    $msg .= "$message\n\n";

    mail($to, $subject, $msg, "From: Yourdomain.com\nReply-To: $email\n");

    ?>

    FLASH FILE

    on (release) {
    if (name eq "" or subject eq "" or message eq "" or email eq "") {
    stop ();
    } else {
    loadVariablesNum ("form.php", 0, "POST");
    gotoAndStop (2);
    }
    }

  7. #7
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    if you post the url of your movie, I could check whether it is actually sending an email variable

    Musicman

  8. #8
    Junior Member
    Join Date
    Aug 2000
    Location
    Jacksonville Florida
    Posts
    28
    I decided to go with formmail and everything submits.

    Only problem is one of the hidden values in formmail is "redirect"

    Is it possible for the redirect value to specify it to stay in the flash file instead of getting another url after it submits the form?

    such as goto a certain frame and stop.
    Flash Aces Design
    http://www.flashaces.com

  9. #9
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    this depends very much on the actual formmail

    Musicman

  10. #10
    Member
    Join Date
    May 2003
    Posts
    80
    Is it me or does it seem like there is no clear cut way to get things to work. Like everyone has their own method, because all of the solutions to this problem that I have read are different.

  11. #11
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    the obvious solution is to identify all the vars that should be expected from the web, document them, and add code to actually pick them up. There are circumstances where just a general pattern is known (e.g. a variable del371 representing a checkbox with the meaning "delete id 371 from database"), and pickup code will use regex
    However, if you are faced with the problem that your web host just upgraded, and you need your site up and running again as soon as possible, you would probably use one of the "collect all vars" methods

    Also, not all servers are configured the same - so solutions might differ as well

    Musicman

  12. #12
    Member
    Join Date
    May 2003
    Posts
    80
    Originally posted by Musicman
    you would probably use one of the "collect all vars" methods

    Musicman [/B]
    How do I collect all vars? I've never had any of my php scripts working 100% perfectly since the upgrade. The funny thing is the server company upgraded the server, but not to the specifications I asked for, and they work for me!

  13. #13
    this trial version is expired
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    6

    Thanks musicman

    Had posted already a tread because of this problem. Should have read your
    fine manual on dealing with te problem. Thanks, Musicman, you rock!?

  14. #14
    Senior Member
    Join Date
    Jan 2006
    Posts
    137
    This is my PHP-code

    <?PHP

    $to = "[email protected]";
    $subject = "RockCity post";
    $message = "Name: " . $theName;
    $message .= "\nEmail: " . $theEmail;
    $message .= "\n\n Message: " .$theMessage;
    $headers = "From: $theEmail";
    $headers .= "\nReply-To: $theEmail";

    $sentOk = mail($to, $subject, $message, $headers);

    echo "sentOk= " . $sentOk;

    ?>

    And this is my Flash code

    var senderLoad:LoadVars = new LoadVars();
    var receiveLoad:LoadVars = new LoadVars();

    sender.onRelease = function() {
    senderLoad.theName = theName.text;
    senderLoad.theEmail = theEmail.text;
    senderLoad.theMessage = theMessage.text;
    senderLoad.sendAndLoad("http://www.lillebo.org/send.php", receiveLoad);
    }

    receiveLoad.onLoad = function() {
    if(this.sentOk) {
    gotoAndStop("success");
    }
    else {
    gotoAndStop("failed");
    }
    }

    The problem is... I get the mail, but the mail contains none of the information it is supposed to contain :/ any suggestions?

    Thank you!
    Last edited by Tempesta; 03-06-2006 at 06:16 PM.

  15. #15
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    you want to add something like
    $theName = $_POST['theName'];
    for all the vars you are sending.
    You should further add the POST option to your sendandload call - sending mails via url parameters may make it appear in browser or server histories, and also is subject to size limits

    Musicman

  16. #16
    Senior Member
    Join Date
    Jan 2006
    Posts
    137
    Ey thaaanks!
    That actually worked perfectly I found a similar post by the maker of the tutorial I followed but he wrote;
    $theName = $_POST[`theName`];
    with some weird quotations and it didnt work.. imagine my frustration :P
    but thanks, have a nice day!

  17. #17
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Didnt know if I should start a new thread but there was an upgrade to pHP releaseed on may 1st.

    Im pretty sure my host has upgraded and Ive since been getting errors that my LoadVars cant find the php doc Im trying to sendAndLoad. Anyone else had any weird stuff happen?

  18. #18
    Senior Member
    Join Date
    Jul 2000
    Posts
    356

    Need Help with Flash Form/PHP

    New Server uses: PHP Version 4.4.1

    1 -- Flash Form used to work fine with the following code in my 'submit' button:

    on (release) {
    /:recipient = "[email protected]";
    /:subject = "feedback form from your site";
    loadVariables ("formmail.php", "", "POST");
    play ();
    }

    2 -- 'formmail.php' has been tested with another HTML form, and works fine.

    Flash won't talk to the .php file. I am not getting the emails.

    Tried a bunch of the other codes posted in this thread, can't get any of them to work either.

    Is there a simple fix for the above button code?

    Thanks very much
    Healthy Earth - Healthy Mankind - A Joyous New Millennium

  19. #19
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    Could you post a link to the actual site?
    is that your php so you could edit it?

    Musicman

  20. #20
    Senior Member
    Join Date
    Jul 2000
    Posts
    356
    Actual site: www.mediashox.com

    Button to Form Mail: EMPLOYMENT

    Yes, the PHP is mine, I can edit it.

    I can upload .fla and .php if you're willing to look at it. I'm very grateful for the help, been trying to fix this for days now with no luck.

    Thanks, Musicman!
    Healthy Earth - Healthy Mankind - A Joyous New Millennium

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