I’m not sure I’m going about this the right way but is there a way to get a mySQL database row id from the address bar url (…com/script.php?id=5) into a swf file? I’ve read all the books, forums, help files, tuts and tried everything I can think of but can’t find an answer. It seems like a pretty basic thing to do but I can’t make it work.
The php script outputs the correct data in the format Flash requires (&data1&data2&etc.) with a url that ends like the one above. I need to have the swf file get the url with the particular id number and read the data it’s putting out. Right now the only way I can make it work is to hard code the full url with the id number in the actionscript like so:
Is there a way to call the url or just the particular id number with the actionscript when the php script calls a different row from the database and the id number changes?
If anyone can help me out here, I’d really appreciate it.
Thanks for responding Eastcoast but I’m starting to feel like I’m on a quest for a non-existent Holy Grail! After Googling flashVars, I’m more confused than ever.
Right now, my php script (http://www…com/script.php?id=5) looks like this:
// Connect to the database
include_once("dbconnect_database.php");
// Request the data
$id = $_GET['id'];
$result = @mysql_query("SELECT id,data1,data2,data3 FROM data_table WHERE id='$id'");
if (!$result) {
exit('<p>Error fetching data_table: ' . mysql_error() . '</p>');
}
$result = mysql_fetch_array($result);
$id = $result['id'];
$data1 = $result['data1'];
$data2 = $result['data2'];
$data3 = $result['data3'];
echo "id=$id&field1=$data1&field2=$data2&field3=$data3"; //which outputs the correct string when run by itself.
// Request the swf file
$id = $_GET['id'];
$swf = @mysql_query("SELECT id,imagepath FROM swf_table WHERE id='$id'");
if (!$swf) {
exit('<p>Error fetching swf: ' . mysql_error() . '</p>');
}
// Display the swf file
$swf = mysql_fetch_array($swf);
$id = $swf['id'];
$imagepath = $swf['imagepath'];
include ($imagepath);
and the embedding code with the flashvars added like so…
… and which is probably wrong as far as the values are concerned since all I’m getting in the swf flash file are $id, $data1, etc. or nothing at all depending on the actionscript I include. I really have no idea what the actionscript needs to be for flashVars.
Thanks Chris. I think I found the solution in your answer to the comment at the bottom of your page with the article about flashvars. All I really needed to get was the id from the url of the php page and