View Full Version : Correct PHP Syntax
jimjiminyjimjim
January 19th, 2010, 10:35 AM
Just a quick question -
html .="<param name=FlashVars value='imageFilename=$row[pic]'> "
As I don't think the $row[pic] should appear within the ' ' think it should be somthing like this:
html .="<param name=FlashVars value='imageFilename='.$row[pic].'> "
but am not sure of the correct syntax.
Templarian
January 19th, 2010, 11:36 AM
$html .= '<param name="FlashVars" value="imageFilename='.$row['pic'].'">';
I think is what you are looking for.
jwilliam
January 19th, 2010, 12:12 PM
Currently, the PHP interpreter will evaluate pic in $row[pic] as a string, which is what you'd expect. However, it's generally considered bad practice as its not really guaranteed to work that way. Always use a string in your associative arrays, like Templarian said ($row['pic']).
jimjiminyjimjim
January 19th, 2010, 12:18 PM
Hi - thanks for the reply.
I'm still a little confused!! Here is the full bit of code:
$html .= "
<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='200' height='200' id='imagetest' align='middle'>
<param name=FlashVars value='imageFilename=myphpvariable'>
<param name='allowScriptAccess' value='sameDomain' />
<param name='allowFullScreen' value='false' />
<param name='movie' value='imagetest.swf' />
<param name='quality' value='high' /><param name='bgcolor' value='#996699' />
<embed src='imagetest.swf' FlashVars='myphpvariable' quality='high' bgcolor='#996699' width='200' height='200' name='imagetest' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' />
</object>
";
I'm just embeding a flash movie but want to pass my php variables into the flash file. I've used the word myphpvariable where I want it to go.
I'm a bit confused by the previous answer. I've been using double quotes to start the html string such as:
$html .= "<div id= 'test'>";
but should I use:
$html .= '<div id= "test">';
the other way round?
Thanks
Templarian
January 19th, 2010, 12:29 PM
HTML uses double quotes for attributes (id="blah").
Simply end the string with a single quote append the variable (with a "."), and continue writing the string.
For instance:
'<div id="'.$varaible.'">foobar</div>'
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.