Jump to content


Photo

Almost there... I think!


  • Please log in to reply
10 replies to this topic

#1 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 25 February 2006 - 09:53 PM

Please take the time to help me out as I'm really close (at least I think I am) to getting this code right. I think I've almost got my videos to play the way I want on my site, thanks to the help I've gotten from the tutorials and the forum however I'm having a bit of a problem.

Please take a look at my code:

include 'library/config.php';
include 'library/opendb.php';

$query  = "SELECT id, name, path, title FROM upload2";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
    echo "Database is empty <br>";
} 
else
{
    while(list($id, $name, $path) = mysql_fetch_array($result))
    {
?>
    <a href="downloadtitle.php?id=<?=$id;?>"><?=$title;?></a> <br>

<td>
<div align="center">
<OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280" 
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 STANDBY="Loading Microsoft Windows Media components... TYPE="application/x-oleobject" VIEWASTEXT>
<PARAM name="autoStart" value="true">
<PARAM name="url" value="<?=$path;?>">
<PARAM name="wmode" value="transparent">
<PARAM name="uiMode" value="full">
<PARAM name="loop" value="false">
<EMBED NAME="EmbedmediaPlayer" TYPE="application/x-mplayer2" SRC="<?=$path;?>" 
WIDTH="320" HEIGHT="280"></EMBED> 
</OBJECT>

Problem is that this displays multiple embedded media players on the page, one for every entry in my table.

How do I modify the code so it only plays the selected video using a particular URL such as ..../mediaplayer.php?=12 where 12 would be the particular id of the video that I want to play?

THANKS SO MUCH !

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 25 February 2006 - 10:02 PM

try this:

<?php

include 'library/config.php';
include 'library/opendb.php';

$id = $_GET['id'];

if ($id == "") {
    $query  = "SELECT id, name, path, title FROM upload2";
    $result = mysql_query($query) or die('Error, query failed');
    while(list($id, $name, $path) = mysql_fetch_array($result)) { ?>   
        <a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?= $id; ?>"><?= $title; ?></a> <br>
        <?php
    }
} else {
    $query = "SELECT name, path, title FROM upload2 WHERE id = '$id'";
    $result = mysql_query($query);
    $r = mysql_fetch_array($result, MYSQL_ASSOC);
    ?>    
            <div align="center">
            <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"
            CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
            CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 STANDBY="Loading Microsoft Windows Media components..." TYPE="application/x-oleobject" VIEWASTEXT>
            <PARAM name="autoStart" value="true">
            <PARAM name="url" value="<?= $r['path']; ?>">
            <PARAM name="wmode" value="transparent">
            <PARAM name="uiMode" value="full">
            <PARAM name="loop" value="false">
            <EMBED NAME="EmbedmediaPlayer" TYPE="application/x-mplayer2" SRC="<?= $r['path']; ?>"
            WIDTH="320" HEIGHT="280"></EMBED>
            </OBJECT>
    <?php
}    
mysql_close();
?>


#3 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 25 February 2006 - 11:18 PM

Works like a charm!

I'm trying to add a title over the video player using:
<?php echo $title;?>
Right above the code that starts

<div align="center">
            <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"

However nothing shows up... Do you know why?

#4 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 12:03 AM

[!--quoteo(post=349429:date=Feb 25 2006, 06:18 PM:name=davinci)--][div class=\'quotetop\']QUOTE(davinci @ Feb 25 2006, 06:18 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Works like a charm!

I'm trying to add a title over the video player using:
<?php echo $title;?>
Right above the code that starts

<div align="center">
            <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"

However nothing shows up... Do you know why?
[/quote]


Ok well I figured out how to do it by copying the way you inserted variables and used this code

<?= $r['title']; ?>

Not sure why it works the way it does but at least I managed to get it to work. Thanks for your help!

#5 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 05:23 AM

Hey, thought I may you ask since we are already on the topic.

Right now we have it set up that the file is played at ../mediaplayer.php?id=16

Is there a way to make it that each video in the table has its own html page generated, maybe something along the lines of ../videofilename.html instead of ../mediaplayer.php?id=x?


Thanks again!

#6 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 26 February 2006 - 01:38 PM

[!--quoteo(post=349490:date=Feb 26 2006, 12:23 AM:name=davinci)--][div class=\'quotetop\']QUOTE(davinci @ Feb 26 2006, 12:23 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Is there a way to make it that each video in the table has its own html page generated, maybe something along the lines of ../videofilename.html instead of ../mediaplayer.php?id=x?
[/quote]

You could, but why?

You would end up with a bunch of .html files on your server, and they would all be exactly the same, execpt for the filename and the name of the video to be played. And, if you ever had to change where the media player looked for it's information, or anything else that would be a "global" change, you would have to go back and change all those files, not just one.

#7 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 07:20 PM

Well if this is better for the long term I will keep it this way.

Just something that I don't like about people just changing the =id?15 to all different numbers to find videos instead of using my sites navigation.

But, of course wouldn't be worth it if it takes a lot of work to update later.

Site is really coming along, I'll shoot you a link if you're interested when its finished.

#8 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 09:32 PM

I've added a play count entry in to my video table...

How do I have the record updated with every play?

#9 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 26 February 2006 - 09:38 PM

Execute this query:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] videos SET playcount = (playcount + 1) WHERE id = '$id' [!--sql2--][/div][!--sql3--]

#10 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 10:47 PM

I added that query like this:
<?php
}
} else {
$query = "SELECT name, path, title FROM upload2 UPDATE videos SET playcount = (playcount + 1) WHERE id = '$id'";
$result = mysql_query($query);
$r = mysql_fetch_array($result, MYSQL_ASSOC);
?> 

Also tried adding a new query:
<?php
include 'library/config.php';
include 'library/opendb.php';

mysql_select_db($mysql);
$query = "UPDATE upload2 SET playcount = (playcount + 1) WHERE id = '$id'".

mysql_query($query) or die('Error, insert query failed');

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');

include 'library/closedb.php';
?>

Clearly its wrong... Where does it belong?

#11 davinci

davinci
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 26 February 2006 - 11:13 PM

Plays recorded but qetting this error:

Warning: mysql_close(): no MySQL-Link resource supplied in /home/xxxxx/public_html/test2/video.php on line 78

Used this code:

<?php

include 'library/config.php';
include 'library/opendb.php';

$query = "UPDATE upload2 SET playcount = (playcount + 1) WHERE id = '$id'";

mysql_query($query) or die('Error, insert query failed');
include 'library/closedb.php'; 

?>

So I removed the line "include 'library/closedb.php';" and it works now. Is what I'm doing dangerous in any way because it works like this! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users