PDA

View Full Version : php to PHPObject problem


projectatlanta
03-20-2005, 07:15 PM
I have a php script that prints out

&title=My Title&comments=my comments&

what I want to do is pass title and comments into a PHPObject in flash, but I only get one or the other, not both


class MyClass {
var $title = '';
var $comments = '';

function MyClass() {
$this->init();
}
function init() { }
function setTitle($vTitle) { $this->title = $vTitle; }
function setComments($vComments) { $this->comments = $vComments; }
function addToDb() {
// [mysql connect code]
$addTitle = $this->title;
$addCom = $this->comments;
$insert = "INSERT INTO my_table VALUES($addTitle, $addCom)";
// [more mysql code]
}
}


and in the first frame...

phpMyClass = new PHPObject("MyClass");
phpMyClass.onInit = function() {}

myData = new LoadVars();
myData.onLoad = function(){
getInfo();
};

function getInfo() {
phpMyClass.setTitle = myData.title;
phpMyClass.setComments = myData.comments;
}

myData.load("http://localhost/flashremote/test.php");

btnSave.onRelease = function() {
phpMyClass.addToDb();
}


if I leave the code as is, only the title gets added to the db.
if I comment out phpMyClass.setTitle = myData.title then the comments
will get added, so it seems like it can't handle more than one variable.

if I take out the phpMyClass functions and set to a dynamic text
or whatever, I'll get both variables :confused: