Making a Video Player.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Now that I read all of the stuff that Jcart told me to do in his post, I am almost there.

Code: Select all

<?php 
$username= "muot_video"; 
$password= "video"; 
$database= "muot_videos"; 
$connection = mysql_connect('localhost',$username,$password); 
$clause = ''; 
if (!empty($_GET['ID'])) { 
   $clause  = 'WHERE ';  
   $clause .=  (is_numeric($_GET['ID'])  
      ? '`id` ' 
      : '`Fileame` ' 
   ); 
   $clause .= '= \''. mysql_real_escape_string($_GET['ID']) .'\' LIMIT 1';  
} 
    
$sql = 'SELECT `Filename` FROM `videos` '. $clause;  

$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

echo '<EMBED SRC="/pages/videos/'.$row['fileName'].'" AUTOSTART=true></EMBED>';
?>
this is where I am at now.

I get a parse error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/muot/public_html/newsite/videos/play.php on line 19

Line 19

Code: Select all

<?php
$row = mysql_fetch_assoc($result);
Might have done it wrong but it is what I thought to do.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I almost got it.

I am getting the video player now. But it is playing the video that is first on the list.

code as of now

Code: Select all

<?php 
$username= "muot_video"; 
$password= "video"; 
$database= "muot_videos"; 
$connection = mysql_connect('localhost',$username,$password); 
mysql_select_db($database);
$clause = ''; 
if (!empty($_GET['ID'])) { 
   $clause  = 'WHERE ';  
   $clause .=  (is_numeric($_GET['ID'])  
      ? '`id` ' 
      : '`Fileame` ' 
   ); 
   $clause .= '= \''. mysql_real_escape_string($_GET['ID']) .'\' LIMIT 1';  
} 
    
$sql = 'SELECT `Filename` FROM `videos` '. $clause;  

$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

echo '<EMBED SRC="/pages/videos/'.$row['Filename'].'" AUTOSTART=true></EMBED>';
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php 
$username= "muot_video"; 
$password= "video"; 
$database= "muot_videos"; 
$connection = mysql_connect('localhost',$username,$password); 
mysql_select_db($database);
$clause = ''; 
if (!empty($_GET['ID'])) { 
   $clause  = 'WHERE ';  
   $clause .=  (is_numeric($_GET['ID'])  
      ? '`id` ' 
      : '`Fileame` ' 
   ); 
   $clause .= '= \''. mysql_real_escape_string($_GET['ID']) .'\' LIMIT 1';  
} 
    
$sql = 'SELECT `Filename`, `id` FROM `videos` '. $clause;  

$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result) == 1) {
   $row = mysql_fetch_assoc($result);
   echo '<EMBED SRC="/pages/videos/'.$row['Filename'].'" AUTOSTART=true></EMBED>'; 
}
else {
   while ($row = mysql_fetch_assoc($result)) {
      echo '<a href="/play.php?id='.$row['id'].'">'.$row['FileName'].'</a> <br />';
   }
}
Like I already told you to do..

but this is seriously the last time.. I just want to see this thread finish in the near future :wink:
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I just get a blank white page now.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I edited it.. try now.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Still white.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

post your code...
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Code: Select all

<?php  
$username= "muot_video";  
$password= "video";  
$database= "muot_videos";  
$connection = mysql_connect('localhost',$username,$password);  
mysql_select_db($database); 
$clause = '';  
if (!empty($_GET['ID'])) {  
   $clause  = 'WHERE ';   
   $clause .=  (is_numeric($_GET['ID'])   
      ? '`id` '  
      : '`Fileame` '  
   );  
   $clause .= '= \''. mysql_real_escape_string($_GET['ID']) .'\' LIMIT 1';   
}  
     
$sql = 'SELECT `Filename`, `id` FROM `videos` '. $clause;   

$result = mysql_query($sql) or die(mysql_error()); 

if (mysql_num_rows($result) == 1) { 
   $row = mysql_fetch_assoc($result); 
   echo '<EMBED SRC="/pages/videos/'.$row['Filename'].'" AUTOSTART=true></EMBED>';  
} 
else { 
   while ($row = mysql_fetch_assoc($result)) { 
      echo '<a href="/play.php?id='.$row['id'].'">'.$row['FileName'].'</a> <br />'; 
   } 
} 
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

whats the source?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

the source for the video?

i am going to the link http://www.mysite.com/play.php?id=4 and id 4 in my DB is a video with the file name.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

html source

if your in IE go to View -> Source

firefox go to View -> Page Source
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Code: Select all

<a href="/play.php?id=1"></a> <br /><a href="/play.php?id=2"></a> <br /><a href="/play.php?id=3"></a> <br /><a href="/play.php?id=4"></a> <br /><a href="/play.php?id=5"></a> <br /><a href="/play.php?id=6"></a> <br /><a href="/play.php?id=7"></a> <br /><a href="/play.php?id=8"></a> <br /><a href="/play.php?id=9"></a> <br /><a href="/play.php?id=10"></a> <br /><a href="/play.php?id=11"></a> <br /><a href="/play.php?id=12"></a> <br /><a href="/play.php?id=13"></a> <br /><a href="/play.php?id=14"></a> <br />
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

the reason why the link has no name is because

Code: Select all

'.$row['FileName'].
should be

Code: Select all

'.$row['Filename'].
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

This thread is busted. Jcart helped me on MSN and solved it in a jiffy.

Thank You everybody!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Finally got around to doing my New Years resolution.. help someone out even though you have school work to do :lol:

Anyways, now that thats over, I can go back to being evil..
Post Reply