usa_hodson
10-13-2007, 04:57 PM
Hi,
I've just moved over to the Mac and Flash 8, and I'm trying to re-publish some applications. I'm using AMFPHP to communicate between Flash and MySQL database online. The server is obviously installed with the AMFPHP components, and my gateway is also working correctly - when I have the NetConnectionDebugger running It connects to the gateway and sends a call to the login service.
But I have tried without success to get a response from the service. The service has not changed at all since it last worked, and has the following content:
include_once("http://www.sprinkal.com/educate/enterprise/services/inc_sql.php");
class login
{
################################################## ##############################
# The following parameters of mysql_pconnect should match the database access #
# requirements stored in inc_sql.php #
################################################## ##############################
var $dbhost = HOSTNAME;
var $dbname = DATABASE;
var $dbuser = USERNAME;
var $dbpass = PASSWORD;
function login() {
################################################## ##############################
# Method table is required by Flash to use functions written in PHP and SQL... #
################################################## ##############################
$this->methodTable = array (
"validate_login_student" => array (
"description" => "Checks database for username + password provided by Flash",
"access" => "remote"
###### Must be set to 'remote' for Flash to use the functions ##################
);
function validate_login_student($sUsername, $sPassword, $sSchool) {
###### Define function name and parameters required ############################
$sSelect = "SELECT * FROM student WHERE username = '$sUsername' AND
password = '$sPassword' AND school = '$sSchool'";
###### Data retrieval from Database ############################################
$rsData = mysql_query($sSelect);
###### the query is run and data given to the defined data holder - $rsData ####
return $rsData;
###### Return the data retrieved, to Flash #####################################
}
My inc_sql file contains the correct database username and password as per the previously working version in the following format:
<?php
########################
# SQL parameters
########################
//////////////////////////////////////////////////////////////////
//Defines the parameters used by setup.php to install the database
//////////////////////////////////////////////////////////////////
define ("USERNAME","xxxxxxxxxx");
define ("PASSWORD","************");
define ("HOSTNAME","dbxxx.oneandone.co.uk");
define ("DATABASE","dbxxxxxxxxx");
?>
The Flash code in the AS window is as follows to create a connection to the database and send a request:
// ************************************************** ******************************
// Include files necessary for Remoting debugging and coding
// ************************************************** ******************************
//import mx.remoting.debug.NetDebug;
//NetDebug.initialize();
//import mx.remoting.NetServices;
//NetServices.initialise();
//#include "NetDebug.as"
//#include "NetServices.as"
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
NetDebug.initialize();
// ************************************************** ******************************
// Remoting settings - allow connection to the php files and database
// ************************************************** ******************************
NetServices.setDefaultGatewayUrl("http://www.sprinkal.com/educate/enterprise/gateway.php");
conn = NetServices.createGatewayConnection("http://www.sprinkal.com/educate/enterprise/gateway.php");
login = conn.getService("/services/login", this); //connects to the login php file
student = conn.getService("/services/student", this); //connects to the student php file
teacher = conn.getService("/services/teacher", this); //connects to the teacher php file
sendmail = conn.getService("/services/formToMail", this); //connects to the login php file
//Create a result handler for student login validation
function validate_login_student_Result(rsData){
//trace(rsData); //Checks we have a result when testing
if(rsData.length>0){
v_firstname = rsData.getItemAt(0).firstname;
v_score = parseInt(rsData.getItemAt(0).score);
v_target = parseInt(rsData.getItemAt(0).targetscore);
v_pcomplete = parseInt(rsData.getItemAt(0).pcomplete);
v_group = rsData.getItemAt(0).group1;
//trace("The group: "+rsData.getItemAt(0).group1);
//We call these remoting functions immediately to populate the doneworksheet variables
//thus making it simple to know when a worksheet has already been completed.
student.doneworksheet1(v_username);
//trace("Made first call");
} else {
login_error._alpha = 100;
login_verify._alpha = 0;
}
}
But I'm not getting a result back from the database...
Any suggestions? Please?
Thanks in advance,
James
I've just moved over to the Mac and Flash 8, and I'm trying to re-publish some applications. I'm using AMFPHP to communicate between Flash and MySQL database online. The server is obviously installed with the AMFPHP components, and my gateway is also working correctly - when I have the NetConnectionDebugger running It connects to the gateway and sends a call to the login service.
But I have tried without success to get a response from the service. The service has not changed at all since it last worked, and has the following content:
include_once("http://www.sprinkal.com/educate/enterprise/services/inc_sql.php");
class login
{
################################################## ##############################
# The following parameters of mysql_pconnect should match the database access #
# requirements stored in inc_sql.php #
################################################## ##############################
var $dbhost = HOSTNAME;
var $dbname = DATABASE;
var $dbuser = USERNAME;
var $dbpass = PASSWORD;
function login() {
################################################## ##############################
# Method table is required by Flash to use functions written in PHP and SQL... #
################################################## ##############################
$this->methodTable = array (
"validate_login_student" => array (
"description" => "Checks database for username + password provided by Flash",
"access" => "remote"
###### Must be set to 'remote' for Flash to use the functions ##################
);
function validate_login_student($sUsername, $sPassword, $sSchool) {
###### Define function name and parameters required ############################
$sSelect = "SELECT * FROM student WHERE username = '$sUsername' AND
password = '$sPassword' AND school = '$sSchool'";
###### Data retrieval from Database ############################################
$rsData = mysql_query($sSelect);
###### the query is run and data given to the defined data holder - $rsData ####
return $rsData;
###### Return the data retrieved, to Flash #####################################
}
My inc_sql file contains the correct database username and password as per the previously working version in the following format:
<?php
########################
# SQL parameters
########################
//////////////////////////////////////////////////////////////////
//Defines the parameters used by setup.php to install the database
//////////////////////////////////////////////////////////////////
define ("USERNAME","xxxxxxxxxx");
define ("PASSWORD","************");
define ("HOSTNAME","dbxxx.oneandone.co.uk");
define ("DATABASE","dbxxxxxxxxx");
?>
The Flash code in the AS window is as follows to create a connection to the database and send a request:
// ************************************************** ******************************
// Include files necessary for Remoting debugging and coding
// ************************************************** ******************************
//import mx.remoting.debug.NetDebug;
//NetDebug.initialize();
//import mx.remoting.NetServices;
//NetServices.initialise();
//#include "NetDebug.as"
//#include "NetServices.as"
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
NetDebug.initialize();
// ************************************************** ******************************
// Remoting settings - allow connection to the php files and database
// ************************************************** ******************************
NetServices.setDefaultGatewayUrl("http://www.sprinkal.com/educate/enterprise/gateway.php");
conn = NetServices.createGatewayConnection("http://www.sprinkal.com/educate/enterprise/gateway.php");
login = conn.getService("/services/login", this); //connects to the login php file
student = conn.getService("/services/student", this); //connects to the student php file
teacher = conn.getService("/services/teacher", this); //connects to the teacher php file
sendmail = conn.getService("/services/formToMail", this); //connects to the login php file
//Create a result handler for student login validation
function validate_login_student_Result(rsData){
//trace(rsData); //Checks we have a result when testing
if(rsData.length>0){
v_firstname = rsData.getItemAt(0).firstname;
v_score = parseInt(rsData.getItemAt(0).score);
v_target = parseInt(rsData.getItemAt(0).targetscore);
v_pcomplete = parseInt(rsData.getItemAt(0).pcomplete);
v_group = rsData.getItemAt(0).group1;
//trace("The group: "+rsData.getItemAt(0).group1);
//We call these remoting functions immediately to populate the doneworksheet variables
//thus making it simple to know when a worksheet has already been completed.
student.doneworksheet1(v_username);
//trace("Made first call");
} else {
login_error._alpha = 100;
login_verify._alpha = 0;
}
}
But I'm not getting a result back from the database...
Any suggestions? Please?
Thanks in advance,
James