Reputation: 19
Working on a project that involves people signing up to the website and uploading a video, the thing is I have created a file upload form and it works perfectly, I head over to the database and check the users table and I see the video uploaded I then head into my PHP code and initialize the variable:
$Getvid = " ";
Then I fetch the row
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) { $vid = $row ["vid"]; }
After that I place
$Getvid = '< source src="user/'.$u.'/'.$vid.'" >';
if($vid == NULL) {
$Getvid = '< source src="image/Movie on 2013-07-24 at 13.43.mov" type="video/mp4" >';
}
To get video files that a user have uploaded and echo it out on he/she page and also if the vid row is null then the script would show a default video that I have stored in the database
After that I echo out the video on the users page
< video width="320" height="240" controls>
< source src="< ?php echo $vid; ? > " >
</video>
But for some reason the video doesn't show also the default doesn't work unless I source it specially like this:
<video width="320" height="240" controls>
<source src="image/Movie on 2013-07-24 at 13.43.mov" type="video/mp4" >
</video>
Upvotes: 1
Views: 8046
Reputation: 470
Two potential sources of the problem, you shouldn't store your files with spaces in their names and you haven't specified a type for your video.
The SRC should contain a valid URL and therefore you should have %20 or + in your PHP string in stead of the spaces.
Note: As mentioned by Fisk, your php tags are wrong due to the spacing. You use the PHP echo short-form by replacing
< ?php echo $vid; ? >
by
<?= $vid; ?>
Upvotes: 0
Reputation: 52882
PHP will not be invoked if you're actually typing < ?php
in the source code. It will need to be in a single tag, such as <?php
. When you have fixed that, compare the output from the PHP code with your working example and see where it differs. If you want a more exact answer on that, add the generated HTML together with the HTML you're expecting to your question.
You're also using the same variable in different paths; one place you're appending image/ before the video name, while your variable doesn't seem to contain the path.
Upvotes: 0