Hi There,
I have spent many days tearing my hair out trying to get this simple flash code to work.
I have four text fields named player,tournament,position,prize and a submit button.
I have a working mysql database. The php file without the POST variables (i.e. using static data) works fine.
I just cannot get the flash to talk to the php correctly. I have looked at many examples and tutorials and forums, but am at a loss.
I have had many flash errors over the days. At the moment it is ArgumentError: Error #1063: Argument count mismatch on actions::main/processLogin(). Expected 0, got 1
Any help would be amazing!
<?php
$player = $_POST['player'];
$tournament = $_POST['tournament'];
$position = $_POST['position'];
$prize = $_POST['prize'];
mysql_connect("localhost", "root","poker");
mysql_select_db("poker");
mysql_query("INSERT INTO results(player,tournament,position,prize) VALUES
('$player','$tournamnet','$position','$prize')");
?>
package actions {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class main extends MovieClip {
public function main ():void {
submit_button.buttonMode = true;
submit_button.addEventListener(MouseEvent.MOUSE_DOWN, processLogin);
tournament.text = "";
player.text = "";
position.text = "";
prize.text = "";
}
public function processLogin ():void {
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("php/controlpanel.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpVars.player = player.text;
phpVars.tournament = tournament.text;
phpVars.position = position.text;
phpVars.prize = prize.text;
phpLoader.load(phpFileRequest);
}
}
}