cortez Posted March 10, 2009 Share Posted March 10, 2009 Hello all Been battling with this for a little while and am very close. Hoping someone can help me fill in the final piece I need here. I'm retrieving a url variable with php. I am trying to send the name of a picture to swfobject variable in order to display a picture in a flash zoom script. <body> <div id="zoom"></div> <?php $links = mysql_connect("localhost", "Username", "XXXXXX") ; $res=mysql_select_db("xxxxx",$links); if(is_numeric($_GET['id'])){ $id=mysql_real_escape_string($_GET['id']); }else{ $id="The current id is not a number!"; } if($id){ $query = "select * from links where id='$id'"; $results = mysql_query($query)or die("Query error\n".mysql_error()); while ($line = mysql_fetch_assoc($results)) { echo $line['description']; } mysql_close($links); }else{ echo $id; } ?> <script type="text/javascript"> // <![CDATA[ var so = new SWFObject('zoom.swf', 'zoom', '600px', '600px', '8', '#CCCCCC'); so.useExpressInstall('swfobject/expressinstall.swf'); so.addParam("wmode","transparent"); so.addVariable("image", "<?php echo $line['image'] ; ?>"); so.write("zoom"); // ]]> </script> </body> The description Text pulls up fine and I can reference the rest of the info in the row no problem just stuck on getting it into the flash file now. Anyone had experience with this before? I'm assuming it's because I'm closing the php script before I'm retrieving the variable but I can't seem to include the Javascript in echo I tried that with no love. Link to comment https://forums.phpfreaks.com/topic/148858-solved-get-url-variable-php-send-it-to-swfobject/ Share on other sites More sharing options...
cortez Posted March 11, 2009 Author Share Posted March 11, 2009 Okay with the help of swfobject forum I've got everything talking together. Thought I'd share it here. Just need to create global variable to reassign it to the swfobject variable. Very useful for flash lovers! $myimageparam = ""; $links = mysql_connect("localhost", "Username", "XXXXXX") ; $res=mysql_select_db("xxxxx",$links); if(is_numeric($_GET['id'])){ $id=mysql_real_escape_string($_GET['id']); }else{ $id="The current id is not a number!"; } if($id){ $query = "select * from links where id='$id'"; $results = mysql_query($query)or die("Query error\n".mysql_error()); while ($line = mysql_fetch_assoc($results)) { echo $line['description']; $myimageparam = $line['image']; } mysql_close($links); }else{ echo $id; } ?> <script type="text/javascript"> // <![CDATA[ var so = new SWFObject('zoom.swf', 'zoom', '600px', '600px', '8', '#CCCCCC'); so.useExpressInstall('swfobject/expressinstall.swf'); so.addParam("wmode","transparent"); so.addVariable("image", "<?php echo $myimageparam; ?>"); so.write("zoom"); // ]]> </script> </body> Link to comment https://forums.phpfreaks.com/topic/148858-solved-get-url-variable-php-send-it-to-swfobject/#findComment-782202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.