Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-26-2006, 02:49 PM   #1
Registered User
Join Date: Apr 2006
Posts: 14
Default Flash sendAndLoad to MySQL PHP problem

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:


$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)
_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");

if i trace(c) in the output window I get the following.......


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

griffles is offline   Reply With Quote
Old 04-27-2006, 01:17 PM   #2
Registered User
Join Date: Apr 2006
Posts: 24

You run both the sendAndLoad and getURL to the same php script at the same time? Remove the getURL (as the php script will only recognize $_GET if incoming variables are from the getURL) and try again. If you want to test the return result, you don't have to use getURL to do that. You can trace the "c" content from within the function showContent().

c.sendAndLoad("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php", c, "POST");
i_am_a_lazy_man is offline   Reply With Quote
Old 04-27-2006, 03:08 PM   #3
Registered User
Join Date: Apr 2006
Posts: 14
Default cheers for that

that was the problem mate, you clearly cannot use the getURL function at the same time......

griffles is offline   Reply With Quote
Old 05-28-2008, 07:32 AM   #4
Peak Studios Boulder, CO
Join Date: Mar 2002
Location: Boulder, CO
Posts: 214
Wink How about this instead...

Check out Peak Studios Flash PHP MySQl extension for AS2 and AS3. I don't know the exact link but the have it on their home page at http://peakstudios.com

It will make your coding a much happier time!
quincewyss is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash MX actionscript PHP and mySQL - freezes peoples computers! Help. makemode ActionScript 1.0 (and below) 5 05-28-2008 07:38 AM
Flash + PHP + MySql ... News rionbr Server-Side Scripting 4 05-28-2008 07:35 AM
Some Flash Video Converter Tools Compare terry117 Detention 7 05-18-2006 02:08 AM
sendAndLoad with PHP bug? Flash 6 works, Flash 7 fails dwagner ActionScript 1.0 (and below) 3 09-26-2005 05:19 PM
Php + flash problem, flash gets values but browser also prints them al024597 ActionScript 1.0 (and below) 3 08-10-2005 03:56 PM

All times are GMT. The time now is 07:07 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.