[Solved] Embedding dynamic swf filename with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dmacman1962
Forum Newbie
Posts: 14
Joined: Wed Mar 10, 2004 2:58 pm

[Solved] Embedding dynamic swf filename with PHP

Post by dmacman1962 »

Hi,

I am trying to get embed the filename of a SWF file dynamically. The issue I am having is not the dynamics, but mixing the HTML - PHP - SWF info. I am getting the variable from a REQUEST from the URL and that variable is the name of the SWF I want to display. Here is my code so far:

Code: Select all

<? 
$dbHost = "xxx.xxx.net";
$dbName = "xxx";
$dbUser = "xxx";
$dbPass = "xxx";
$connmts = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error(mysql_error(),E_USER_ERROR); 

$link = @mysql_connect($dbHost, $dbUser, $dbPass);
if (!$link){
	$errorMsg = "Could not connect to server";
	print "&result=Fail&errorMsg=$errorMsg";
	exit;
}
if (!@mysql_select_db($dbName)){
  $errorMsg = "Could not select $dbName database";
  print "&result=Fail&errorMsg=$errorMsg";
  exit;
}
$hold = $_REQUEST['merchant'];
	  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="260">
          <param name="movie" value="/images/$hold.swf">
          <param name="quality" value="high">
          <embed src="/images/$hold.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="260"></embed>
        </object>
        <br>'
?>
What I changed from the embedded HTML Flash to make it dynamic is "$hold.swf".

It orignally had the filename in it and I made it dynamic. I know that this boils down to mixing PHP and HTML, but I am still a little grey in this area.

Thanks in advance,

Dmacman
Last edited by dmacman1962 on Sat Mar 13, 2004 10:14 am, edited 3 times in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Instead of..

Code: Select all

$hold = $_REQUEST['merchant'];
try..

Code: Select all

$hold = $_GET['merchant'];
Mark
dmacman1962
Forum Newbie
Posts: 14
Joined: Wed Mar 10, 2004 2:58 pm

Dynamic swf data

Post by dmacman1962 »

I tried that and it didn't do anything. The request was working OK. The problem is I changed the name of the swf from eri000272.swf to $hold.swf so that the name of the swf is dynamic.

The challenge is that I had to enclose the HTML info in php code and now the swf is not showing up.

I know it has to do with embedding the HTML in ' ' . I just am not sure if I did it correctly.

Thanks,

Dmacman
dmacman1962
Forum Newbie
Posts: 14
Joined: Wed Mar 10, 2004 2:58 pm

NOT SOLVED !! I Dont know who put solved!

Post by dmacman1962 »

I posted this question and someone posted that it was solved. It is not. I did not post that and the problem still exists. As I stated, I believe it has to do with my embedding of the HTML and PHP.

Thanks,

Dmacman
User avatar
allenmak
Forum Newbie
Posts: 8
Joined: Sat Mar 13, 2004 9:53 am
Location: Hong Kong

Re: [Not - Solved!] Embedding dynamic swf filename with PHP

Post by allenmak »

Hello, I guess you have missed the word "print" for the Flash plugin part
At here, for my normal scripting habit
I won't ask PHP to process my HTML scripts, already the time won't be shortened a lot.

for example, if I want only to change a word for a passage, I will simply do this.

Hello, my name is <?php print $name; ?>.
So, PHP Parser will only handle <?php print $name; ?>
This way can also reduce the problem of quotation signs or whatever.
So, you can try to modify your scripting and see whether it helps or not. :o

Code: Select all

<?php
// some beforehand scripts here
?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="260">
          <param name="movie" value="/images/$hold.swf">
          <param name="quality" value="high">
          <embed src="/images/<?php print $_GET["merchant"]; ?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="260"></embed>
        </object>
        <br>
dmacman1962
Forum Newbie
Posts: 14
Joined: Wed Mar 10, 2004 2:58 pm

Awesome !!!!

Post by dmacman1962 »

Thanks allenmark,

You got me going down the correct path. I just had to modify what you posted to concatenate the ".swf" onto the variable name and it worked!

Here is the final code that worked:

Code: Select all

object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="260">
          <param name="movie" value="/images/<?php print $_GET["merchant"]."."."swf"; ?>" >
          <param name="quality" value="high">
          <embed src="/images/<?php print $_GET["merchant"]."."."swf"; ?>"" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="260"></embed>
        </object>
I really appreciate your help.

Thanks everyone,

Dmacman
Post Reply