thirteen13 Posted April 16, 2010 Share Posted April 16, 2010 Hi I have the following script: <?php $table = 'web_site_content'; $tableVars = 'web_site_tmplvar_contentvalues'; $id = $modx->documentObject['id']; $sql = "Select * from $tableVars where contentid = $id and tmplvarid = 2"; $result = $modx->db->query($sql); if($row = $modx->db->getRow($result)) { ?> <div id="banner"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="746" height="235"> <param name="movie" value="<?php echo $row["value"]; ?>" /> <param name="quality" value="high" /> <embed src="<?php echo $row["value"]; ?>" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="746" height="235"></embed> </object> </div> <?php } else { $sql = "Select * from $tableVars where contentid = $id and tmplvarid = 1"; $result = $modx->db->query($sql); if($row = $modx->db->getRow($result)) { echo'<div id="banner"><img src="'.$row["value"].'" width="746" height="235" /></div>'; } } ?> Basically it checks whether there is a flash banner uploaded and loads it into a div. If there isn't a flash banner uploaded then it loads the image. The image loads without a problem when there isn't a flash item, but when there is a flash item, instead of the flash item, it loads the following error message: " /> " quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="746" height="235"> Any suggestions? Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/ Share on other sites More sharing options...
Sergey Popov Posted April 16, 2010 Share Posted April 16, 2010 Use htmlspecialchars() function to encode special characters such as double quote and < > in the value: htmlspecialchars($row["value"]); Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042905 Share on other sites More sharing options...
thirteen13 Posted April 16, 2010 Author Share Posted April 16, 2010 I have tried your suggestion. My snippet now looks like this: <div id="banner"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="746" height="235"> <param name="movie" value="<?php echo htmlspecialchars($row["value"]); ?>" /> <param name="quality" value="high" /> <embed src="<?php echo htmlspecialchars($row["value"]); ?>" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="746" height="235"></embed> </object> </div> but it still shows the same error as before Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042906 Share on other sites More sharing options...
cs.punk Posted April 16, 2010 Share Posted April 16, 2010 What is in $row['value']? Check that... Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042911 Share on other sites More sharing options...
thirteen13 Posted April 16, 2010 Author Share Posted April 16, 2010 The value which $row["value"] gets is: assets/files/banner.swf Any idea? Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042912 Share on other sites More sharing options...
cs.punk Posted April 16, 2010 Share Posted April 16, 2010 Well iI just tried this: <?php $row = 1; if($row = 1) { ?> <div id="banner"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="746" height="235"> <param name="movie" value="" /> <param name="quality" value="high" /> <embed src="" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="746" height="235"></embed> </object> </div> <?php } else { echo'<div id="banner"><img src="site.jpg" width="746" height="235" /></div>'; } ?> And it works fine?.. Try it yourself. Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042915 Share on other sites More sharing options...
cs.punk Posted April 16, 2010 Share Posted April 16, 2010 Show your HTML source. . Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042917 Share on other sites More sharing options...
Sergey Popov Posted April 16, 2010 Share Posted April 16, 2010 In your code, top two lines make no sense.. especially second line - assignment instead of comparing Well iI just tried this: <?php $row = 1; if($row = 1) { ?> <div id="banner"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="746" height="235"> <param name="movie" value="" /> <param name="quality" value="high" /> <embed src="" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="746" height="235"></embed> </object> </div> <?php } else { echo'<div id="banner"><img src="site.jpg" width="746" height="235" /></div>'; } ?> And it works fine?.. Try it yourself. Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042919 Share on other sites More sharing options...
thirteen13 Posted April 16, 2010 Author Share Posted April 16, 2010 First of all thanks for the replies I may have to upload different flash banners for different pages. So it is not practical the way you did it. I need the PHP and SQL to carry out the same transactions as my original code. Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042921 Share on other sites More sharing options...
cs.punk Posted April 16, 2010 Share Posted April 16, 2010 In your code, top two lines make no sense.. especially second line - assignment instead of comparing Sorry meant this: <?php $row = 1; if($row == 1) { } Oh and thirteen13 was just making an example. The problem lies somewhere else. Show your html source. Link to comment https://forums.phpfreaks.com/topic/198723-loading-flash-from-php/#findComment-1042923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.