hexcode Posted July 11, 2014 Share Posted July 11, 2014 (edited) <html> <head> <script type=\"text/javascript\" src=\"swfobject.js\"></script> </head> <body> <script type=\"text/javascript\"> var multiplayer = new SWFObject(\"player.swf?xml=config.xml&player_skin=skin.swf\", \"multiVideoPlayer\", \"361\", \"283\", \"7\", \"#FFFFFF\", true); multiplayer.write(\"flashcontent\"); </script> </body> </html> Hi, Could anyone help make the above code run inside my PHP file? When loaded, I just get a blank page and I know the paths to files are correct. Thank you Edited July 11, 2014 by hexcode Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted July 11, 2014 Share Posted July 11, 2014 Why are all the double quotes escaped? Where is this code placed in your PHP? Quote Link to comment Share on other sites More sharing options...
hexcode Posted July 11, 2014 Author Share Posted July 11, 2014 (edited) <?php if($user->data['is_registered']) { echo "<html> <head> <script type=\"text/javascript\" src=\"swfobject.js\"></script> </head> <body> <script type=\"text/javascript\"> var multiplayer = new SWFObject(\"player.swf?xml=config.xml&player_skin=skin.swf\", \"multiVideoPlayer\", \"361\", \"283\", \"7\", \"#FFFFFF\", true); multiplayer.write(\"flashcontent\"); </script> </body> </html>"; } else { echo '<html> <head></head> <body>Please login to access this page.</body> </html>'; } ?> Hi, Above is a slimmed down version of the full file. How it works is if the user is logged in, it will display the Javascript section. If not, it will ask them to log in. I used to call the the swf file a different way using "object" as seen below, but this is a complete different swf setup and I can not use the old call system. <html> <head> <script type=\"text/javascript\">if (top.frames.length!=0) top.location=self.document.location;</script> </head> <body> <object type=\"application/x-shockwave-flash\" data=\"player.swf\" width=\"325\" height=\"235\"> <param name=\"movie\" value=\"player.swf\"></object> </body> </html> Edited July 11, 2014 by hexcode Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted July 11, 2014 Share Posted July 11, 2014 Try this.... <html> <head> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <?php if($user->data['is_registered']){ echo <<<EOT <script type="text/javascript"> var multiplayer = new SWFObject("player.swf?xml=config.xml&player_skin=skin.swf", "multiVideoPlayer", "361", "283", "7", "#FFFFFF", true); multiplayer.write("flashcontent"); </script> EOT; } else{ echo "Please login to access this page!"; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
hexcode Posted July 11, 2014 Author Share Posted July 11, 2014 (edited) Try this.... Hi, Thanks you for trying, but this also returns an blank page. Edited July 11, 2014 by hexcode Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 11, 2014 Share Posted July 11, 2014 As indicated by chriscloyd's code - do not duplicated code. You apparently only want to change the content of the page and there is no need to replicate the creation of the HTML, HEAD and other tags. Use php to determine the dynamic content and "plug it in" to the template of the page. I would make one change to chriscloyd's code and determine the content BEFORE the output is started. As for a blank page, did you view the HTML source of the page? I'm not very good with flash and don't know if the code you have would produce and output. I modified the above code to add some debugging logic so you can verify if the page is getting executed correctly. <?php $ouput = "Please login to access this page!"; $debug = "Condition is false"; if($user->data['is_registered']) { $ouput = '<script type="text/javascript"> var multiplayer = new SWFObject("player.swf?xml=config.xml&player_skin=skin.swf", "multiVideoPlayer", "361", "283", "7", "#FFFFFF", true); multiplayer.write("flashcontent"); </script>'; $debug = "Condition is true"; } ?> <html> <head> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <?php echo $output; ?> <br> <?php echo $debug; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 11, 2014 Share Posted July 11, 2014 Turn on error checking and see if $user has a problem. That's got to be it. Quote Link to comment Share on other sites More sharing options...
hexcode Posted July 11, 2014 Author Share Posted July 11, 2014 (edited) As indicated by chriscloyd's code - do not duplicated code. You apparently only want to change the content of the page and there is no need to replicate the creation of the HTML, HEAD and other tags. Use php to determine the dynamic content and "plug it in" to the template of the page. I would make one change to chriscloyd's code and determine the content BEFORE the output is started. As for a blank page, did you view the HTML source of the page? I'm not very good with flash and don't know if the code you have would produce and output. I modified the above code to add some debugging logic so you can verify if the page is getting executed correctly. <?php $ouput = "Please login to access this page!"; $debug = "Condition is false"; if($user->data['is_registered']) { $ouput = '<script type="text/javascript"> var multiplayer = new SWFObject("player.swf?xml=config.xml&player_skin=skin.swf", "multiVideoPlayer", "361", "283", "7", "#FFFFFF", true); multiplayer.write("flashcontent"); </script>'; $debug = "Condition is true"; } ?> <html> <head> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <?php echo $output; ?> <br> <?php echo $debug; ?> </body> </html> Yup, it works. False when logged out and True when logged in. I already knew the base script worked. The problem is the new way of calling this swf player. Just so you can try this on your end, the script is here: http://www.tufat.com/script146.htm Click the try it free link or use http://www.tufat.com/files_lgpl/script_146.zip That way you can try the call the music player on your own server using my modified php. I think the problem is this just the way this swf scrip is called. Because on my old music player the "object" based calling worked while the new way of calling this swf with javascript does not load right when in php. <script type=\"text/javascript\"> var multiplayer = new SWFObject(\"player.swf?xml=config.xml&player_skin=skin.swf\", \"multiVideoPlayer\", \"361\", \"283\", \"7\", \"#FFFFFF\", true); multiplayer.write(\"flashcontent\"); </script> Edited July 11, 2014 by hexcode Quote Link to comment Share on other sites More sharing options...
hexcode Posted July 11, 2014 Author Share Posted July 11, 2014 Thanks for everyone's help, but I found the problem. I was missing a tag that I thought would not be needed. <div id=\"flashcontent\"><strong>You need to upgrade your Flash Player</strong></div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.