Using Flash MX 2004, PHP and MySQL to connect to a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
leegee3
Forum Newbie
Posts: 10
Joined: Thu Mar 29, 2007 7:28 am

Using Flash MX 2004, PHP and MySQL to connect to a database

Post by leegee3 »

Hi guys, im new to all this PHP stuff, and am currently pulling my hair out with my problem.

I have a uni assignment that I am doing in Flash MX 2004, all run locally on a machine and not via the web. I have recently installed PHP, Apache, MySQL and Navcat MySQL free trial.

My database was created in Navcat MySQL, GUI based.

I have a simple form in Flash, with Username input and password input. The submit button has the ActionScript as follows...


on (release, keyPress "<Enter>") {
if (user != "" && pass != "") {
status = "Wait...";
loadVariablesNum("newlogin.php", 0, "POST");
}
}

This code, im sure, is correct...

My PHP file contains the following...

<?
$user=$_POST['user'];
$pass=$_POST['pass'];

//connect to database
if ($user && $pass){
mysql_pconnect("mysql.localhost","root","") or die ("didn't connect to mysql");
mysql_select_db("tester") or die ("no database");
//make query
$query = "SELECT * FROM userpass WHERE username = '$user' AND password = '$pass'";
$result = mysql_query( $query ) or die ("didn't query");

//see if there's an EXACT match
$num = mysql_num_rows( $result );
if ($num == 1){
print "status=You're in&checklog=1";
} else {
print "status=Sorry, but your user name and password did not match a user name/password combination in our database. Usernames and passwords are entered in from a different file. Thank you for visiting test login script!!&checklog=2";
}
}
?>


Im not sure if the 'mysql.localhost' is correct, this should be my host name, which I am not sure of, but all other information is correct, database name, table name, and field names, but I just cant get it to do anything. PLEASE HELP, im clueless
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

Try debugging php and flash separately. Make a simple html form and submit it to your php script. If there are any error, correct them. Once you're sure php script works properly, replace the html form with flash.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Duplicate thread. Locked.
Locked