Establishing a connection to my Database in mysql

Hello, I recently built my first database in phpMyAdmin. I really find this fascinating. My table has id, username, password and age in columns.
In Flash CS6 i have an as3 file. In notepad i have a php file. I am trying to connect my Flash login system to mysql database through php to create a login system in Flash.
I have tested both files and there not working. I am using a login function in flash that sends the username/password/ages variables to the PHP script. the PHP script is then checking that those variables are stored in the database.
Here is the code that i am using:

ActionScript 3

//Requesting the php
var phpFileRequest: URLRequest = new URLRequest("http://localhost");

phpFileRequest.method = URLRequestMethod.POST;

//Assing the variable names
//Build the variable
var phpVars:URLVariables = new URLVariables();

//Building the loader
var phpLoader:URLLoader = new URLLoader();
phpLoader.addEventListener(Event.COMPLETE, showResult); = email.text;
phpVars.username = username.text;
phpVars.password = password.text;


phpLoader.addEventListener(Event.COMPLETE, showResult);

// Add an event listener for the submit button and what function to run
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);

// Validate form fields and send the variables when submit button is clicked
function ValidateAndSend(event:MouseEvent):void{
status_txt.text ="";
    //validate form fields
    if(!email_txt.length) {

        status_txt.text = "Please enter your email address.";

    } else if(!password_txt.length) {

        status_txt.text = "Please enter your password.";

    } else {

        // Ready the variables for sending = email_txt.text;
     variables.pass = password_txt.text;

        // Send the data to the php file

        status_txt.text = "Processing...";

    } // close else after form validation

} // Close ValidateAndSend function //////////////

php file


$link = mysql_connect("localhost","example","password");

$email = $_Post['email'];
$username = $_POST['username'];
$password = $_POST['password'];

$query = 'SELECT * FROM users;
$results = mysql_query($query)

$login_counter = mysql_num_rows($query);

if ($login_counter > 0) {

while ($data = mysql_fetch_array($query)) {

$userbio = $data["name"];

echo "systemResult=$userbio";


} else {

echo "systemResult=The login details dont match our records.";



Any help on what could be going wrong would be great!

What do you mean by “they don’t work”? Do you get an error message or just not the result you expected?

The PHP code you’ve posted has a syntax error in it - unclosed single quote on the first line. And if you fix that, the PHP doesn’t seem to be doing any checking against the variables you’re (presumably) POSTing to it from the Flash script, you’re just SELECTing all users in the table.

Do you get the expected records if you run your query in a MySQL command line? Does your table actually have the data you’re looking for?

So lets see; real obvious problems in the PHP script:

Line 7 -> $_Post => $_POST (yes, it matters)
Line 11 -> Unclosed quote.
Line 12 -> Missing semicolon.
Line 17 -> Checking condition should be == 1 (Because you’ve made your database entries unique, correct?)
Line 19 -> Because condition should be == 1, while is unnecessary (Should be exactly 1 record)
Line 34 -> Closing brace without an opening brace.