Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 06:23
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  crossdomain issue?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: crossdomain issue?  (Read 5119 times)
Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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:
$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
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« 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
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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.
Logged
Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« 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
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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)
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« 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
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« 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
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« 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
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #12 on: 12/08/08, 11:11 »

The error is asyncronous, that means it comes from PHP return value. Publish and upload

Jorge
Logged

Pluda
Senior Programmer
****
Posts: 270


View Profile
« 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
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!