472,122 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

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:

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

$cant=0 ;
echo "$cant=$row[title]&$cant=$row[descr]&$cant=$row[test]";
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.onLoad = function(succes){
for(var i=0; i<this.cant; i++){
titletx.text = this.title
descrtx.text = this.descr
testx.text = this.test
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?
Jan 29 '07 #1
3 8511
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
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
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:


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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.