473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

AS3, PHP & MySQL not Loading...

I need help with few problems trying to connect my .SWF in AS3 to my MySQL DB through PHP.

I've been reading few articles, tutorials and followed all their explanations, but somehow I have to be misunderstanding something, because my code does not work the proper way.

The thing is that I have a an SWF with a triangle called PLAYER, x position = 60 and y position = 120.
The FlashMovie also contains a star Movie Clip (called CONTROL) that works as a listener.
It is supposed that when I click over the star, AS3 must send the name and position of the triangle to my save.php file.
Then, my save.php file must catch and send the POST variables to my MYSQL database.

AS3 CODE
Expand|Select|Wrap|Line Numbers
  1. //----------------------------------
  2. //Import Libraries
  3. //----------------------------------
  4. import flash.net.*;
  5. import flash.events.*;
  6. //----------------------------------
  7. //var declarations || The Flash movie is loaded in http://www.erimm.com/index.php
  8. //----------------------------------
  9. var url:URLRequest=new URLRequest("http://www.erimm.com/save.php");
  10. var variables:URLVariables=new URLVariables();
  11. var loader:URLLoader=new URLLoader();
  12. //----------------------------------
  13. //trigger listener creation
  14. //----------------------------------
  15. CONTROL.addEventListener(MouseEvent.CLICK,insertar);
  16. //----------------------------------
  17. //loader listener creation
  18. //----------------------------------
  19. function insertar(e:MouseEvent){
  20.     loader.addEventListener(Event.COMPLETE, carga);
  21.     loader.load(url);
  22. }
  23. //----------------------------------
  24. //sending variables
  25. //----------------------------------
  26. function carga(e:Event) {
  27.     variables.user="PLAYER";
  28.     variables.xpos= PLAYER.x;
  29.     variables.ypos= PLAYER.y;
  30.     url.data=variables;
  31.     url.method=URLRequestMethod.POST;
  32.     loader.dataFormat = URLLoaderDataFormat.VARIABLES; 
  33.     sendToURL(url);
  34. }
  35.  
Up to here, AS3 must be loading my save.php file POSTING the variables.user .xpos and .ypos.

Now the Save.php CODE
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. //-----
  3. // Conex Vars Info
  4. //-----
  5. $host = "XXXXXXX"; //Hidden due to security reasons
  6. $username = "XXXXXXX"; //Hidden due to security reasons
  7. $pass = "XXXXXXXX"; //Hidden due to security reasons
  8. //-----
  9. // Conex creation
  10. //-----
  11. $dbase = "BLABLA";
  12. $conex = mysql_connect($host,$username,$pass);
  13. mysql_select_db($dbase,$conex);
  14. //-----
  15. // Catching Vars
  16. //-----
  17. $user = $_POST['user'];
  18. $xpos = $_POST['xpos'];
  19. $ypos = $_POST['ypos'];
  20. //-----
  21. // Sending Vars to DB in orther to update $user row (PLAYER row)
  22. //-----
  23. $consulta = "UPDATE users SET xpos=$xpos, ypos=$ypos WHERE user=$user";
  24. mysql_query($consulta,$conex);
  25. ?>
  26.  
The movie is loaded in a different page than Save.php. It is index.php, with a title and few examples i did.

If I'm not wrong, it must be working the following way.

Index.php-----[JUEGO.SWF]----vars---->Save.php---->MYSQL

Can anybody help me with this?
Thank you so much, guys!

Eri.
Oct 4 '10 #1
0 1456

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Google Mike | last post by:
To my surprise last month, my dad wanted to start dabbling in PHP and MySQL or pgSQL. I've been helping him out a bit. He's into athletic medicine and wants to have a website to help athletes and...
1
by: Ken | last post by:
First time I have installed mysql. I have not been able to connect to the server/database with a new php installation. I have installed IIS. Do I need this for mysql? The php works fine. ...
7
by: AF | last post by:
I am a real novice to php and MySQL, with about a week's worth of reading and self tutoring. I have an urgent need to publish a database of information and need some guidance on how to do this. ...
0
by: dohnut | last post by:
Here's one for some bored problem solver :) I ran across this earlier today and fixed it, but don't exactly know why. (that usually only happens in C :) I'm using Perl version 5.8.0 btw. ...
7
by: Nick Bolton | last post by:
Hello, Maybe a common case, but I really want to not so much as migrate from PHP/MySQL to C# .NET but learn the new language. I have made maybe 3/4 very simple systems using C# .NET, but they...
0
by: taras.di | last post by:
Hi everyone, I've come across an extremely strange problem. The exact same query in both mysql command line client, and mysql query browser gives entirely different results. I was hoping someone...
4
by: AJ | last post by:
Hi all, Is using ASP.NET with MYSQL a plausible option?? Do you loose a lot of functionality??? Is it combersome?? Buggy?? My company is considering migrating to .NET and MYSQL may very ...
1
by: Lennie De Villiers | last post by:
Hi, I'm running PHP 4.4.2 and mySQL on MS Windows XP Home Edition in IIS 6.0. When I try to connect to mySQL from PHP I get the following error message: Warning: mysql_connect(): Client does...
3
by: Toni | last post by:
I want to use asp.net & mysql. I am trying to download mysql db and tools from www.mysql.com but i can find everything what I need. Can somebody tell me where I can download DB, Tools, OleDB...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.