Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-26-2006, 02:49 PM   #1
griffles
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:


<?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
griffles is offline   Reply With Quote
Old 04-27-2006, 01:17 PM   #2
i_am_a_lazy_man
Registered User
 
Join Date: Apr 2006
Posts: 24
Default

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");
getURL("http://nemesis.bournemouth.ac.uk/~jgriffiths/contact/login.php")
i_am_a_lazy_man is offline   Reply With Quote
Old 04-27-2006, 03:08 PM   #3
griffles
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......

legend!
griffles is offline   Reply With Quote
Old 05-28-2008, 07:32 AM   #4
quincewyss
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
Reply


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 05:27 PM.

///
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.