PDA

View Full Version : help loading data


toke
06-19-2007, 08:50 PM
Hi,

I successfully created a magnet board and able to save the data and their position on the database. However, I am struggling with loading these data back to flash. What is the best way to do this? I'm using PHP and MySQL. The unique variable send between the two movies (magnetic board and the reader.swf) is the session varialble. Here is php code for the reader, which i know it's wrong.


<?php
// database info
$dbhost = "localhost";
$dbname = "temp";
$dbuser = "tempe";
$dbpass = "notavailable";

// connect to database
mysql_connect($dbhost, $dbuser, $dbpass) or die ("Cannot connect: ".mysql_error());
mysql_select_db($dbname) or die (mysql_error());

$result = mysql_query("SELECT poemtitle, session FROM magnetic_board");
$cant = 0;
while($row=mysql_fetch_array($result)){
echo "Poemtitle$cant=$row[poemtitle]&Session$cant=$row[session]&";
$cant++;
}
echo "cant=$cant";
?>
<HTML>
<HEAD>
<TITLE>reader</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<!--Preparing the card, please wait --><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="640" height="480" title="poemReader">
<PARAM NAME=movie VALUE="reader.swf?session=<?php echo $session; ?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="reader.swf?session=<?php echo $session; ?>" quality=high bgcolor=#FFFFFF WIDTH=640 HEIGHT=480 pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></EMBED>
</OBJECT>
</BODY>
</HTML>


thank you
:confused:

LOLFlash
06-20-2007, 01:41 AM
to communicate with database amfphp ver1.2
upload it on your server and it works

toke
06-20-2007, 03:26 AM
thank you but I'm not using amfphp ver1.2 and I have no time to study it at this moment. i think I need to compare session variable sent in the email against the one in the DB but I don't know how. Anyone?

toke
06-20-2007, 08:07 PM
Is there a way I can send the variable or check the variable in the email against the one on the DB?

LOLFlash
06-20-2007, 09:11 PM
use loadVars

not clear yet what your goal

but check email if it is in database use loadVars and if server respond -OK, getURL with email address in GET or POST and like you did rout it to PARAMS

Please give more explanation of logic

toke
06-20-2007, 10:44 PM
My goal is to capturing the data from one flash file, put them into the database and send the email to the users where they can see it (different flash file). The concept is almost like the ecard tutorial that Jesse has in the tutorial section. But I tried his example but it didn't work so, I got the saving part figured out and also the email part with url+session. for example go to http://viewthis.com/reader.php?session=2007062016441U to view the poem. Now, I'm having a problem loading back the right session and the right data back to the reader.swf file. so, is it possible to send variable (in this case the session variable) from the email back to reader.php and compare it to the one on the DB?

LOLFlash
06-21-2007, 12:32 AM
Ok
I got it. I never saw this tutorial, I think Jesse use session variable as a rid (random ID);
lets call it rid so don't mix a words.

try this: after first time you got $session assign tor $rid variable and use link like:

http://viewthis.com/reader.php?rid=2007062016441U;

$rid = $_GET['rid'];

$result = mysql_query("SELECT poemtitle, session AS rid FROM magnetic_board WHER session = '$rid' ");

if(mysql_num_rows($result) !=1) {echo "suppose to be only one row";exit;}
else
{
$row = mysql_fetch_assoc($result);

$poemtitle =$row['poemtitle'];

}


.................................................. .

.................................................. ..
<param name="FlashVars" value="rid=<?php echo $rid.'&poemtitle='$poemtitle; ?>"

toke
06-21-2007, 04:22 PM
Ok.. I'll try it right now and will let you know. Yes, the RID is what I use too since I follow Jesse's concept too. thank you so much for your help. :D

toke
06-21-2007, 05:01 PM
um.. can you explain this please?


if(mysql_num_rows($result)!=1){
echo "suppose to be only one row";
exit;
}else{
$row = mysql_fetch_assoc($result);
$poemtitle=$row['poemtitle'];
}


I always get the "suppose to be only one row". but there are about 5 rows on the magnetic_board table already. so the else statement never get to execute.

LOLFlash
06-21-2007, 08:13 PM
just delete if statment. I thought you have unic rid for user

toke
06-21-2007, 08:34 PM
Thank you. I deleted the if statement and now it's showing on php what i want it to be. but i still have a problem making them appear right on the reader.swf.


here is the reader.php file

<?php
// database info


$rid = $_GET['rid'];

// connect to database
mysql_connect($dbhost, $dbuser, $dbpass) or die ("Cannot connect: ".mysql_error());
mysql_select_db($dbname) or die (mysql_error());

$result = mysql_query("SELECT poemtitle, session AS rid FROM magnetic_board WHERE session='$rid'");

/*if(mysql_num_rows($result)!=1){
echo "suppose to be only one row";
exit;
}else{
$row = mysql_fetch_assoc($result);
$poemtitle=$row['poemtitle'];
}
*/

$row = mysql_fetch_assoc($result);
$poemtitle=$row['poemtitle'];
//print "session=$rid";
echo "&poemtitle=$poemtitle&session=$rid";
?>
<HTML>
<HEAD>
<TITLE>reader</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<!--Preparing the card, please wait --><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="640" height="480" title="poemReader">
<PARAM NAME=movie VALUE="reader.swf?session=<?php echo $rid; ?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="reader.swf?session=<?php echo $rid; ?>" quality=high bgcolor=#FFFFFF WIDTH=640 HEIGHT=480 pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></EMBED>
</OBJECT>
</BODY>
</HTML>


not sure how i should link this reader.php file to the reader.fla

toke
06-22-2007, 06:11 PM
got it :cool: thank you LOLFlash for helping me out.