Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-12-2008, 12:17 PM   #1
Vjeko
Ambassador Of Good Will
 
Vjeko's Avatar
 
Join Date: Aug 2007
Location: Croatia
Posts: 82
Default retrieve highscore form PHP to Flash

I've been searching solution for a week now. There are few problems.

1. I'm trying to save highscore from Flash to PHP (WORKS)
2. I'm trying to retrieve highscore form PHP to Flash (LOSING MY SANITY)

So my sending variables works, but getting them back doesn't.

Here's the code:
ActionScript Code:
/* *getMyResults() *This method is for getting the results from PHP * */ private function getMyResults():void {   var myLoader:URLLoader = new URLLoader();   var myRequest:URLRequest = new URLRequest("Database/highscore.php");   myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;   myLoader.load(myRequest);   myLoader.addEventListener(Event.COMPLETE, onDataLoad); }         /* *onDataLoad() *This method fills text boxes in fla file with retrieved data * */ private function onDataLoad(event:Event):void {   var loader1:URLLoader = URLLoader(event.target);   for(var i:Number = 0; i < loader1.data.cant; i++)   {     this["Ime"+i].text = loader1.data["Ime"+i];     this["Bodovi"+i].text = loader1.data["Bodovi"+i];   }   //tracing loaded data   trace(loader1.data);   //this is irrelevant - only graphic for game   otkriRezultate();      isponova_btn.visible = true;   isponova_btn.enabled = true;   isponova_btn.addEventListener(MouseEvent.CLICK, ponovo); }

Ok, here is the deal. If I have absolute path in URLRequest:
ActionScript Code:
var myRequest:URLRequest = new URLRequest("http://localhost/zapamtiMe/Database/highscore.php");
it WORKS! But only on my machine. When I upload it to internet (on my server) it doesn't work. (I change the path of course).

I don't get why relative path won't work on my machine or anywhere.

When relative path is in the place, i load php code, not echoed values of that php code.

Example:
with relative:
Code:
%3C%3Fphp%0D%0Ainclude%20%27config%2Ephp%27%3B%0D%0A%0D%0A%24result=mysql%5Fquery...
with absolute:
Code:
Ime0=Dibeste&Bodovi0=5424&Ime1=Proba&Bodovi1=5231&Ime2=Maroni&Bodovi2=5161&Ime3=TugaBugaKuga...
Ime means player's name, and Bodovi means player's score.

So relative path is returning php code. I don't get it.

With absolute code, it works when I test my movie in flash, I get results which I want, but PROBLEM is when I test on my localhost (html file) it stops and results are not written in flash.


HINT: It seems (by not loaded graphic which should load) that it stops on onDataLoad function.

I'll attach PHP code from highscore.php:
PHP Code:
<?php
include 'config.php';

$result=mysql_query("SELECT Ime, Bodovi FROM ".$imetablice." WHERE 1 ORDER BY Bodovi DESC LIMIT 10");
$cant 0;
while(
$row=mysql_fetch_array($result))
{
    echo 
"Ime".$cant."=".$row['Ime']."&Bodovi".$cant."=".$row['Bodovi']."&";
    
$cant++;
}
echo 
"cant=".$cant."";
?>
I repeat, highscore.php is working fine, echoing the right thing on screen, but seems like Flash is messing with my head...
I have save.php which saves data to MySQL and it works fine (I also used URLLoader and relative path).

So it WORKS when I have absolute path to highscore.php and when I test it in Flash, anywhere else it DOESN'T WORK (localhost, web server...)

Can anyone help me?

I would be very grateful...

Vjeko
Vjeko is offline   Reply With Quote
Old 01-12-2008, 12:54 PM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

We sometimes lose ourselves with path problems with Flash when it comes to upload all our files and make them work. A good trick I use to make sure that my problems don't come from paths is copy my php in all my server directories and subdirectories and see if my Flash can read one. That seems silly but then I'm sure it's not the path and sometimes it made my PHP working! (then i check to see which PHP file was the one working).
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 01-12-2008, 02:04 PM   #3
Vjeko
Ambassador Of Good Will
 
Vjeko's Avatar
 
Join Date: Aug 2007
Location: Croatia
Posts: 82
Default

I still don't get the problem, but I've solved it.
I used save.php for sending and retrieving results.
Vjeko is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php mail flash form with embedded fonts davekaplan Server-Side Scripting 0 08-30-2007 02:29 AM
about my question ; Tutorial 06 Send Mail Contact Form (PHP and Flash) IRITS ActionScript 2.0 1 08-06-2006 08:55 AM
HELP flash template and php mail form taro Server-Side Scripting 2 02-17-2006 03:33 PM
PHP & Flash mx pro 2004 sending variables on contact form jesse8771 Server-Side Scripting 1 02-02-2006 05:16 PM


All times are GMT. The time now is 05:46 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.