I have managed to get everything working good and kinda hit a snag with returning data to flash.
Heres my code in flash:
var conn = NetServices.createGatewayConnection("http://localhost/amfphp/gateway.php");
var myService = conn.getService("shoutBox", this);
function getShouts() {
myService.getShouts('allShouts');
myTextField = allShouts;
}
Now heres my problem… I need to be able to return the collumns of my mySQL table to flash, in order of newest to oldest. And so far… I can’t get it to work quite right… My current code sends me a VERY long un-orderly array, that I can only seem to see in the NetDebug window.
GetShouts is where I’m having my problem… Any Help? Btw… I’m going to clean it all up once I get it working perfect!
<?php
class shoutBox{
function shoutBox(){
$this->methodTable = array(
"addShout" => array(
//Echoes the passed argument back to Flash (no need to set the return type
"access" => "remote",
"arguments" => array ("userName", "userShout"),
"returntype" => "recordSet"
),
"getShouts" => array(
"access" => "remote",
"arguments" => array ("allShouts"),
"returntype" => "Array"
)
);
}
function addShout($userName, $userShout){
@mysql_connect('localhost', 'root', 'mypass');
@mysql_select_db('mydb');
$query="INSERT INTO shoutbox (userName,userShout) VALUES('$userName','$userShout');";
mysql_query($query);
mysql_close();
}
function getShouts(){
$myArray = array();
@mysql_connect('localhost', 'root', 'mypass');
@mysql_select_db('mydb');
$sql = 'SELECT * FROM shoutbox';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
foreach($row as $key=>$value){
array_push($myArray, $key, $value);
}
}
return $myArray;
mysql_close();
}
}
?>