Flash fails to connect to PHP script

Discussion in 'Game Development (Technical)' started by lennard, Jan 26, 2011.

  1. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    So, here's another one that I suspect Andrew will know the answer to... but anyone can chime in.

    I can contact PHP scripts on my website from my Flash program when I run my Flash program locally in the IDE. Hoist my SWF up to the website and it fails to communicate with the same PHP script.

    Is there some permissions thing I'm failing to set?
     
  2. filharvey

    Original Member

    Joined:
    Feb 4, 2005
    Messages:
    104
    Likes Received:
    0
    Do you have a crossdomain.xml on your server?
     
  3. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    Locally I do which is how I got it to work in the first place. I'd blame it on old age but I've always been absent minded.

    For those following this link (or me googling in the future and coming across this thread - it's happened), I had to place the XML file at the root of my site where .htaccess lives to get it to work.

    Thanks Filharvey.
     
  4. Spore Man

    Indie Author

    Joined:
    Jun 19, 2007
    Messages:
    843
    Likes Received:
    0
    Flash doesnt "connect" to PHP, it's just a URL call. So make sure you put in error checking and error reporting. Dump the errors to a text field so you know what's going on. Chances are it's just a bad URL path.

    Is the SWF and the PHP file on the same domain?
     
  5. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    No, chances are that it was a missing crossdomain.xml file since adding that made it work.
     
  6. andrew

    andrew New Member

    Joined:
    Jan 14, 2007
    Messages:
    487
    Likes Received:
    0
    Yeah, Flash 10 has gotten pretty picky about security and crossdomain.xml files. May also need a Security.allowDomain("*.yourdomainhere.com") as well, depending on what you're trying to do.

    If you ever do any socket-related stuff you will likely need to add a "to-ports" in the crossdomain xml as well so that Flash Player will whitelist the ports...

    - andrew
     
  7. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    Unfortunately the server version of the .swf has stopped communicating with the PHP files again tonight. All I can think is that I got a player update that tightened the security rules somehow? Anybody else encountered this weirdness lately?
     
  8. Maupin

    Original Member

    Joined:
    Jun 28, 2006
    Messages:
    1,183
    Likes Received:
    0
    My stuff still works, using the same player that I used to play your game yesterday when it didn't work.

    Have you changed anything else in the code or your crossdomain.xml file?

    I notice when I point my browser to rustyaxe.com/crossdomain.xml I get your homepage, not an xml file. (Of course perhaps your serverside stuff resides somewhere else.)
     
  9. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    Well, that might have been it - I just uploaded to my website root (not the level above that where I had been putting it) and it started working.

    Not sure why it worked before. Not sure why it was working for people who were registering last night when I couldn't.

    Thanks Maupin.
     
  10. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    and... now it's back to failing.

    I've got to go and get some exercise - maybe a clear head later will help me find the problem.
     
  11. lennard

    Moderator Original Member Indie Author

    Joined:
    Jan 12, 2006
    Messages:
    2,390
    Likes Received:
    12
    I think I've got it now. It's a mystery that it worked sporadically for me an others - maybe different flash players?

    Anyhow, I'm starting to grow a small database of players (41 so far, all came this week) so I think it's time to put some kind of comment system up so I can start getting player feedback.

    Nobody has bought any coins yet...
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer