php - video file name doesn't load correctly
I'm new to PHP. Everything else works on my site okay but I seem to have an issue with this particular piece of code. The$efn
is my file name, and I need to retrieve it from a MySQL database but this code doesn't seem to work. It works in a normal video container but not when using theif
statement.
Any ideas how to fix this?
<?php
$video_container = substr($efn, -3);
if ($video_container == 'mp4') {
echo '<video preload="auto" width="640" height="264" poster="../images/<?php echo $thumb ?>" controls="controls" autoPlay="false">
<source src="<?php echo $efn ?>" type="video/mp4">
</video>';
}
else {
echo '<video height="620" width="480" controls>
<source src="<?php echo $efn ?>" type ="video/avi" />
</video>';
}
?>
Answer
Solution:
You have syntax problem when printing the string. Replace the
<?php echo $fn ?>
section by' . $efn . '
Like this: