Jump to content

[SOLVED] Get URL Variable php send it to SWFOBJECT


cortez

Recommended Posts

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.

 

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.