Maybe you can look at what I am doing, it may be of use to you.
The ActionScript:
[script]
#include "NetDebug.as"
#include "NetServices.as"
#include "DataGlue.as"
if (isGateWayOpen ==null){
//do only once
isGateWayOpen = true;
//make the gateway connection
NetServices.setDefaultGatewayURL("
http://localhost/flashservices/service.php");
gatewayConnection=NetServices.createGatewayConnection();
scdbservice = gatewayConnection.getService("scdbservice");
function addClient() {
var newClient = new Object();
newClient.companyName = CompanyName;
newClient.businessType = BusinessType;
newClient.contactName = ContactName;
newClient.Position = Position;
newClient.phoneNumberAC = PhoneNumberAC;
newClient.phoneNumber = PhoneNumber;
newClient.faxNumberAC = FaxNumberAC;
newClient.faxNumber = FaxNumber;
newClient.mobile = Mobile;
newClient.email = Email;
newClient.postalAddress = PostalAddress;
newClient.city = City;
newClient.state = State;
newClient.country = Country;
newClient.postcode = Postcode;
newClient.streetAddress = StreetAddress;
newClient.sCity = SCity;
newClient.sState = SState;
newClient.sCountry = SCountry;
newClient.sPostCode = SPostCode;
newClient.Url = Url;
newClient.cdrom = CDROM;
newClient.interest = Interest;
trace("sent request. newClient: " + newClient.toString());
scdbservice.addClient(addClientReply, newClient);
}
}
[/script]
Then the PHP script - thanks to Louis Simpson
[script]
function addClient($newClient){
$sql = "INSERT INTO client SET ";
$a = array();
foreach($newClient as $key => $val) {
$a[] = "$key = '".addslashes($val)."'";
}
$sql .= implode(",", $a);
$q = mysql_query($sql);
if(mysql_affected_rows()){
return "Client added successfully";
}else{
return "Error adding record";
}
}
[/script]
All my object properties are named exactly as the corresponding table field title.
Hope this helps.
Luke