469,955 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,955 developers. It's quick & easy.

flash/actionscript load from php

Hello I have a problem: I have a database(mysql) with the following fields:
test, descr, title
I want to display them into a flash file.
Now my php file called list.php (which collect the information from my database) is the following:

<?php
include_once '../library/config.php';
include_once '../library/opendb.php';
$query =mysql_query("SELECT * FROM `$table` ORDER BY(`title`DESC ");

$cant=0 ;
while($row=mysql_fetch_array($query)){
echo "$cant=$row[title]&$cant=$row[descr]&$cant=$row[test]";
$cant++;
}
echo "cant=$cant";
?>

My flash file has 3 input dynamic text (to display the database)called titletx, descrtx, testx.
and I put an actionscript code to call the php file into my flash file here it is:

myData = new LoadVars()

myData.load("www.ilgerss.it/mazzi/list.php")
myData.onLoad = function(succes){
if(succes){
for(var i=0; i<this.cant; i++){
titletx.text = this.title
descrtx.text = this.descr
testx.text = this.test
}
}
else
trace("Error loading data")
}

everything is in one fotogramma: the input dynamic text and the actionscript code.

Can anyone be so kind to tell me why this code do not work? or have any suggestion?
Thanks
Pa.
Jan 29 '07 #1
3 8450
BigMrv
1
I have the same darn problem...... You by chance haven't figured it out have you? I can get mine to load the actual text within the PHP but not the results of the execution..
May 3 '07 #2
Motoma
3,237 Expert 2GB
Try putting some trace functions in to see what you are actually getting when you load list.php.
May 9 '07 #3
ronnil
134 Expert 100+
You cannot reference arrays inside strings in php, this will produce an fatal error if i recall correctly. You also need to encapsulate the argument in the array with quotes.
Just so there's no confusion, i also always escape variable calls too, making the echo statement look like this:

echo $cant . "=" . $row['title'] . '&' . $cant . "=" . $row['descr'] . "&" . $cant . "=" . $row['test'];

since $cant is an increasing integer your string would now look something like this:

0=rowtitle&0=rowdescr&0=rowtest

I'm pretty sure AS treats this string just like PHP would treat a querystring, meaning yoo actually only have one variable, and you overwrite it constantly

The solution would be to either put some square brackets around them (loading it as an array), like this:

echo $cant . "[]=" . $row['title'] . '&' . $cant . "[]=" . $row['descr'] . "&" . $cant . "[]=" . $row['test'];

or use a prefix:

echo 'title_' . $cant . "=" . $row['title'] . '&descr_' . $cant . "=" . $row['descr'] . "&test_" . $cant . "=" . $row['test'];

Either way, try turning on all error messages on your PHP server and check out the response. If that don't work, that's where you start

Another idea might be to set the mimetype of the php file to text.

And like Motoma said... trace every step of the execution.
Jun 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by ASP.NET explorer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.