Welcome, Guest
  • Author Topic: crossdomain issue?  (Read 5879 times)

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    crossdomain issue?
    « on: 12/07/08, 10:52 »
    hello,

    I've one index.php at domain.a
    my index has a embed swf located at subdomain.domain.b

    here (subdomain.domain.b) i've some php that should read domain.a database records

    I got this error (can't connect to database)

    using this as connection

    Code: [Select]
    $connection2 = mysql_connect("localhost", "".$username."", "".$password."") or die ("can't connect to server!");
    mysql_select_db("".$bd."") or die ("can't connect to database!");

    at domain a I've a crossdomain.xml allowing conection to subdomain.domain.b

    What am I missing here?

    Thanks

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #1 on: 12/07/08, 17:07 »
    The crossdomain affect Flash files, not PHP files that doesn't fall under the same restriction. Check that you're using the correct user, host and password

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #2 on: 12/07/08, 17:16 »
    hello,

    thanks for reply :-)

    username, password, database_name, all are fine.
    the problem is session, its a bit confused to make php sessions work from domain to domain, i haven't yet find a cleaner solution to this.

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #3 on: 12/07/08, 17:22 »
    I'm working on this for abaut a week or so...

    this is the thing,

    index.php call a swf in a subdomain. this swf call a php file (listar_coisas.php) witch as a include(conf.php)

    so, basically I need to manage a way of let index.php send a variable (username) to be usable by conf.php, but they are in distinct domains.

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #4 on: 12/07/08, 17:34 »
    For cross calling (an swf calling a PHP in another domain) you need a crossdomain.xml file in domain B, domain A can't grant access to domain B

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #5 on: 12/07/08, 17:46 »
    no, no, swf isn't calling php from another domain


    try to figure this, I can't show link because it doesn't work, sorry


    a     (index.php at DOMAIN A) -> this calls swf

    b     (swf  at SUBDOMAIN.DOMAIN.B   ->  is called from index.php, BUT he works withe some php files that are in this subdomain)

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #6 on: 12/07/08, 17:56 »
    The mandatory domain is the one where the swf resides. Check first all from the same domain, my suspect is that the problem is not related from security policy, since mandatory domain is the one from swf (doesn't matter where the PHP or HTML file that load them is)

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #7 on: 12/08/08, 07:43 »
    I discovered that the problem is within flash, because just using php i can acess to database from my domain or other domain/subdomain.

    using flash, the URLRequest doesn't even fire

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #8 on: 12/08/08, 07:46 »
    Quote
    Check first all from the same domain

    ... so you can spot or not on crossdomain

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #9 on: 12/08/08, 10:11 »
    hello again :-)

    ok, I think the crossdomain is working now, but still a litle(big) problem

    if I use

    var path_php:URLRequest = new URLRequest("../gestor/php/listar_tabelas.php?"+getTimer());

    flash try to load php from index.php domain (this can't work, since there is no php files there)

    If using

    var path_php:URLRequest = new URLRequest("http://my_subdomain.my_domain.com/php/listar_tabelas.php?"+getTimer());

    must be like this, the full path to the php files, but...

    i got this ugly error

    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables$iinit()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()


    after reshearch the web I use something like

    var path_php:URLRequest = new URLRequest("http:"+encodeURIComponent("//")+"my_subdomain.my_domain.com/php/listar_tabelas.php?"+getTimer());

    but now anything fires

    how should I reference my http://subdomain having no ugly error?

    Thanks

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #10 on: 12/08/08, 10:22 »
    Since the script is in another domain, you should pass the complete URL, the error means that the script have some error, use a proxy like http://www.charlesproxy.com to see what the PHP error is

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #11 on: 12/08/08, 10:30 »
    i can't use charles, since the error doesn't alloy me to correctly publish the swf

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: crossdomain issue?
    « Reply #12 on: 12/08/08, 11:11 »
    The error is asyncronous, that means it comes from PHP return value. Publish and upload

    Jorge

    Pluda

    • Senior Programmer
    • ****
    • Posts: 270
      • View Profile
    Re: crossdomain issue?
    « Reply #13 on: 12/08/08, 12:06 »
    got it! :-)))

    it was a & in php echo who was firing that error.

    Thanks a lot for help Jorge

    Pluda