
July 10th, 2005
05:46 AM
Neverside Newbie
Status: Offline!
Flash database
hi, i am new to combining flash and php. How would i display text from my DB in to flash field.
here is what i have for my php pagewhich flash loads.
<?php
mysql_connect("localhost","","");
mysql_select_db("flashphp");
$result = mysql_query("select * from content WHERE name='tom'");
while($r=mysql_fetch_array($result))
{
$name=$r["name"];
$contents=$r["contents"];
$id=$r["id"];
}
?>
<?="&phptxt=$contents"?>
and flash AS:
(frame action)
loadVariablesNum("phpfile.php", 0, "POST");
i have a dynamic txt field with the Var: phptxt
But what i have doesn't work can someone help plz..
Last edited by james182, July 10th, 2005 05:47 AM (Edited 1 times)

July 14th, 2005
06:21 AM
Neverside Newbie
Status: Offline!
I'm pretty php/mysql deficient, but you'll need to echo or print a variable to get it back to flash.. Also, I would look into using the LoadVars object rather than loadVariablesNum (unless you're using Flash 5 or lower)...
___________________
obod | weapons of mass dysfunction

July 14th, 2005
07:41 PM
Neverside Newbie
Status: Offline!
as devonair said, first in the php you need to add the echo statement to your last line.
echo &phptxt."&"; <--the extra & added at the end helps remove any unwanted carriage returns whitespace etc.
then you need to use
LoadVars() object instead
you may also try using the sendAndLoad function as well.
___________________
"Using a key to gouge expletives on another's vehicle is a sign of trust... and friendship."
- Ignignoc, Aqua Teen Hunger Force
-------------------------------------------------------
[ www.hybridart.com ]

July 14th, 2005
09:17 PM
Neverside Newbie
Status: Offline!
When echoing the results in your php, make sure its all in a form like this:
&varname=text&varname2=text&varname3=text
So maybe something like...
<?php
mysql_connect("localhost","","");
mysql_select_db("flashphp");
$result = mysql_query("select * from content WHERE name='tom'");
$count = 1;
while($r=mysql_fetch_array($result))
{
$name=$r["name"];
$contents=$r["contents"];
$id=$r["id"];
echo "&name" . "$count" . "=$name";
echo "&contents" . "$count" . "=$contents";
echo "&id" . "$count" . "=$id";
$count++;
}
echo "&";
?>
That should work, but I havn't tested it.
___________________

Last edited by hamstu, July 14th, 2005 09:18 PM (Edited 1 times)

July 16th, 2005
08:32 AM
Neverside Newbie
Status: Offline!
okay got it working but my text has large spaces between each line how do get rid of that????
example:
jasghdhjgdhjsgdjhgd
asdasdasdasdasd
asdasdasdasdasdasdasdasasd
asdasasdasdasdasdasdas
asdasdasdasd
asdasd...
thats just an example my txt is rendered as HTML...