griffles
04-26-2006, 03:49 PM
Hi all that reads this
I am having a nightmare integrating my flash front end program with a mySQL database. All I need for it to do is query the database for a username and then send a string back to flash. I have hard coded the php script and can return a string so I know it works fine. The php script looks like this:
<?php
mysql_connect("database","username","password");
mysql_select_db("contact");
$tab = $_POST['login'];
$qr = mysql_query("SELECT * FROM users WHERE username = '".$tab."'");
// start output string for flash
$nrows = mysql_num_rows($qr);
if ($nrows == 1) {
$rString= "feedback=Success";
$row = mysql_fetch_array($qr);
$rString .= "&username=".$row['username'];
$rString .= "&firstName=".$row['firstName'];
$rString .= "&credits=".$row['credits'];
}else {
$rString= "feedback=Your username was not found - Please register";
}
echo $rString;
?>
if I run this code with a username that exists in the database in place of $tab there is no problem. The actionscript that is coming from flash is as follows
var c = new LoadVars();
c.onLoad = showContent;
function showContent() {
if (this.feedback == "Success") {
_root.feedback = "You are logged in";
_root.loginUserName = this.username;
_root.firstName = this.firstName;
_root.credits = this.credits;
_root.loggedIn = true;
trace("user name coming from php = "+_root.loginUserName)
gotoAndPlay("success");
}else{
_root.feedback="Username not found, please register";
trace("failure called")
}
}
login_btn.onPress = function() {
_root.feedback = "Logging in, please wait...";
//c.login = _root.userNameText;
c.login = "jules84";
c.sendAndLoad("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php", c, "POST");
getURL("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php")
trace(c);
};
if i trace(c) in the output window I get the following.......
login=jules84&onLoad=%5Btype%20Function%5D
I am pretty sure that there is nothing wrong with the actionscipt as it sends a string. (c.login = jules84 (this name is definately in the database) however I believe the problem to be with the following line
$tab = $_POST login
as if I echo $tab in the script I ALWAYS get nothing!!!!!! Is it possible that the $_POST command is not extracting the information from the string?
This is driving me mad and cant find a logical solution anywhere. Please help me out
Griff
I am having a nightmare integrating my flash front end program with a mySQL database. All I need for it to do is query the database for a username and then send a string back to flash. I have hard coded the php script and can return a string so I know it works fine. The php script looks like this:
<?php
mysql_connect("database","username","password");
mysql_select_db("contact");
$tab = $_POST['login'];
$qr = mysql_query("SELECT * FROM users WHERE username = '".$tab."'");
// start output string for flash
$nrows = mysql_num_rows($qr);
if ($nrows == 1) {
$rString= "feedback=Success";
$row = mysql_fetch_array($qr);
$rString .= "&username=".$row['username'];
$rString .= "&firstName=".$row['firstName'];
$rString .= "&credits=".$row['credits'];
}else {
$rString= "feedback=Your username was not found - Please register";
}
echo $rString;
?>
if I run this code with a username that exists in the database in place of $tab there is no problem. The actionscript that is coming from flash is as follows
var c = new LoadVars();
c.onLoad = showContent;
function showContent() {
if (this.feedback == "Success") {
_root.feedback = "You are logged in";
_root.loginUserName = this.username;
_root.firstName = this.firstName;
_root.credits = this.credits;
_root.loggedIn = true;
trace("user name coming from php = "+_root.loginUserName)
gotoAndPlay("success");
}else{
_root.feedback="Username not found, please register";
trace("failure called")
}
}
login_btn.onPress = function() {
_root.feedback = "Logging in, please wait...";
//c.login = _root.userNameText;
c.login = "jules84";
c.sendAndLoad("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php", c, "POST");
getURL("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php")
trace(c);
};
if i trace(c) in the output window I get the following.......
login=jules84&onLoad=%5Btype%20Function%5D
I am pretty sure that there is nothing wrong with the actionscipt as it sends a string. (c.login = jules84 (this name is definately in the database) however I believe the problem to be with the following line
$tab = $_POST login
as if I echo $tab in the script I ALWAYS get nothing!!!!!! Is it possible that the $_POST command is not extracting the information from the string?
This is driving me mad and cant find a logical solution anywhere. Please help me out
Griff