Hi frnds...
I need to integrate php variable with vedio scripting file.....

i fetch my vedio file path from database...here i need to replace the file=videos/movieimgae.swf ....with $vedio..

<?php
$vedio="vedios/aaa.php";

?>
<SCRIPT type=text/javascript>
var s1 = new SWFObject('player.swf','player','400','300','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=[B]videos/movieimgae.swf[/B]');
s1.write('preview');
                        </SCRIPT>

Dani AI

Generated

Short answer: echoing the PHP path into the player is fine, but do it safely so quotes and special characters don't break JavaScript or the flashvars string. is on the right track; the reliable pattern is either (A) emit a safe JS string from PHP (use json_encode) and build the flashvars in JS, or (B) build the flashvars string on the server and escape it for HTML. Also be aware that browsers today may block Flash — consider migrating to HTML5 video when possible.

Example (safe JS injection — different approach than the posts):

<?php
$videoPath = '/media/path/to/file.swf'; // value from DB
?>
<script>
var src = <?php echo json_encode($videoPath); ?>;   // safe for JS
var flashvars = 'file=' + encodeURIComponent(src);
// pass "flashvars" to your player initialization function
swfobject.embedSWF('your-player.swf', 'playerContainer', '400', '300', '9.0.0', null, flashvars);
</script>

Quick HTML-side alternative (server-built flashvars or HTML5):

<?php
$videoPath = '/media/path/to/video.mp4';
?>
<video controls src="<?php echo htmlspecialchars($videoPath, ENT_QUOTES, 'UTF-8'); ?>">Your browser does not support HTML5 video.</video>

Troubleshooting and cautions:

  • Use json_encode when inserting PHP strings into JS to avoid broken quoting or injection.
  • When building flashvars on the server, URL-encode values (rawurlencode) and escape attributes with htmlspecialchars.
  • Use absolute URLs or confirm relative paths to avoid 404s; check server logs and browser console for errors.
  • Flash is deprecated in modern browsers; prefer HTML5 <video> players or JS libraries for better compatibility and security.

These steps fix the common issues that cause the path not to load and keep the embedding safe and robust.

Recommended Answers

All 2 Replies

Hi....

sry..
in the above code...

<?php
$vedio="vedios/[B]aaa.swf[/B]" ;
?>

is not a php file. its a vedio file.....

Hi frnds...
I need to integrate php variable with vedio scripting file.....

i fetch my vedio file path from database...here i need to replace the file=videos/movieimgae.swf ....with $vedio..

<?php $video="vedios/aaa.php"; ?>
<script type="text/javascript">
  var s1 = new SWFObject('player.swf','player','400','300','9');
  s1.addParam('allowfullscreen','true');
  s1.addParam('allowscriptaccess','always');
  s1.addParam('flashvars','file=[B]<?php echo $video ?>[/B]');
  s1.write('preview');
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.