[PHP-DB] Accessing MySql using Flash while using PHP as the middleware

2003-06-25 Thread Ron Allen
Does anybody have an idea how-to use Flash and PHP to access a MySql
database. I know how to use PHP and mysql with no problem to pull info, but
with Flash I am struggling.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Accessing MySql using Flash while using PHP as the middleware

2003-06-25 Thread Miles Thompson
Adam made a good suggestion - but using LoadVars is better, and if you are 
retrieving text it's easier to bring it back as an xml file, otherwise an 
ampersand stops you cold. Here's my call to the login script to 
authenticate users for a news site when the login button is clicked.

The varSender and varReceiver are recommended by Colin Moock to avoid 
caching. His ActionScript for Flash MX The Definitive Guide, O'Reilly, 
ISBN 0-596-00396-X is worth every penny. Also visit www.moock.org
Values in first_txt.text, last_txt.text, and pass_txt.text come from those 
text boxes.

The variable host is retrieved from a settings.as file in the first frame 
of the movie.

ckval is stored in a shared object so that subsequent logins are automatic.
autologin = true is the key which unlocks the rest of the movie
read is the frame where another script loads the day's news stories, also 
stored in a MySQL database.
frame 7 is for login failed - when I added it I had no space to name it.

So, what does the php script return? Exactly this, with no leading space or 
empty line, and on one line:
ValidLogin=trueckval=some32bitkeyiwonttypeout

(I was tearing my hair out - everything looked RIGHT, yet the movie kept 
failing, dumbly. Then I realized there was a blank like ahead of the 
returned values. Removed it and magic happened.)

Flash is alternately exasperating and wonderful.

HTH - Miles

--- flash code calling PHP script 
function onLogin(){
if(first_txt.length  0  last_txt.length  0  pass_txt.length  0)
{
varSender = new LoadVars();
varReceiver = new LoadVars();
varSender.first_name = first_txt.text;
varSender.last_name = last_txt.text;
varSender.password = pass_txt.text;
varSender.action = 'login';
varSender.sendAndLoad(http://+ host + user_logon.php, 
varReceiver, 'GET');
varReceiver.onLoad = function()
{
if(!this.error  this.CkVal != ){
subs_so.data.ckVal = this.CkVal;
}
if(!this.error  this.ValidLogin == true) {
_root.ValidLogin = this.ValidLogin;
_root.gotoAndStop('read');
} else {
_root.gotoAndStop(7);
}
first_txt.selectable = true;
last_txt.selectable = true;
pass_txt.selectable = true;
loginButton.enabled = true;
}
}
} //end of function onLogin
 end of Flash code ---



At 05:15 PM 6/25/2003 +0200, Ron Allen wrote:
Does anybody have an idea how-to use Flash and PHP to access a MySql
database. I know how to use PHP and mysql with no problem to pull info, but
with Flash I am struggling.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php