Jump to content

Almost there... I think!


davinci
 Share

Recommended Posts

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:

[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>
[/code]

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 !
Link to comment
Share on other sites

try this:

[code]<?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();
?>[/code]
Link to comment
Share on other sites

Works like a charm!

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

[code]
<div align="center">
            <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"
[/code]

However nothing shows up... Do you know why?
Link to comment
Share on other sites

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

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

[code]
<div align="center">
            <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"
[/code]

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

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

Not sure why it works the way it does but at least I managed to get it to work. Thanks for your help!
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

[!--quoteo(post=349490:date=Feb 26 2006, 12:23 AM:name=davinci)--][div class=\'quotetop\']QUOTE(davinci @ Feb 26 2006, 12:23 AM) [snapback]349490[/snapback][/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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 [color=orange]=[/color] (playcount [color=orange]+[/color] 1) [color=green]WHERE[/color] id [color=orange]=[/color] [color=red]'$id'[/color] [!--sql2--][/div][!--sql3--]
Link to comment
Share on other sites

I added that query like this:
[code]
<?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);
?>
[/code]

Also tried adding a new query:
[code]
<?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';
?>

[/code]
Clearly its wrong... Where does it belong?
Link to comment
Share on other sites

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:

[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';

?>
[/code]

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! :)
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.