Making a Video Player.
Moderator: General Moderators
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
WHOAAAAAA,, Thanks for telling me about taco, every space had a hidden character.
Now it connects to the DB
But If I go to the link http://www.example.com/play.php?id=4
It doesnt play, It includes a page that is the path to the video's in this case it would be /pages/videos/
It is not getting the data from the DB.
Now it connects to the DB
But If I go to the link http://www.example.com/play.php?id=4
It doesnt play, It includes a page that is the path to the video's in this case it would be /pages/videos/
It is not getting the data from the DB.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
If your using the code I gave you it was not complete.. I left out fetching the info from the db up to you (even though I gave you code to build the query)..
I would also suggest you look carefully at the logic of the code, especially outputting the embedded source. Think about it, you only want to display a movie if your query returns 1 row (hint mysql_num_rows()).. if not show all movie links
I would also suggest you look carefully at the logic of the code, especially outputting the embedded source. Think about it, you only want to display a movie if your query returns 1 row (hint mysql_num_rows()).. if not show all movie links
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
Ok,
This is where I am at right now.
The problem I have now is that it is giving me this error
This is where I am at right now.
Code: Select all
<?php
$username= "muot_video";
$password= "password";
$database= "muot_videos";
mysql_connect('localhost',$username,$password);
$result = mysql_query('SELECT `Filename` from `muot_videos` where `ID`=$id');
if (!$result) {
die('Could not query:' . mysql_error());
}
echo mysql_result($result, 2);
?>Seems so simple but I think I am already connected to the DB.Could not query:No database selected
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
OK, I can connect now.
But now I get this error.
But now I get this error.
play.phpCould not query:Unknown column '$id' in 'where clause'
Code: Select all
<?
$username= "muot_video";
$password= "video";
$database= "muot_videos";
$connection = mysql_connect('localhost',$username,$password);
mysql_select_db($database, $connection);
$result = mysql_query('SELECT `Filename` from `videos` where `ID`=$id');
if (!$result) {
die('Could not query:' . mysql_error());
}
echo mysql_result($result);
?>That's because PHP is parsing $id litterally, because you are using single quotes which do not expand variables which I explained to you in IM and feyd has already mentioned. Replace the single quotes around the query with double quotes, or ideally concate that $id in with some kind of filtering:
Code: Select all
$sql = 'select * from table where `id` = ' . (int)$id ' limit 1'- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York