Jump to content

[SOLVED] Php variable in an embedded object??


calist

Recommended Posts

I am very very new to PHP, I am building a website in which there are like 30 youtube videos for a training series.  I would like to put the youtube links all in a MySQL database and then have them returned as embedded videos in a window in the file but I can't seem to find any way of doing this.  Is it even possible.

 

Here is what I was trying...

Main Source File:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" type="text/css" href="mystyle.css" />
<title>The Recipe Center</title>
<body>

<table width="100%" border="0"> <tr>

<td id="header" height="90" colspan="3">

<?php 
include("header.inc.php"); 
?>

</td>

</tr>
<tr> 

<td id="nav" width="15%" valign="top"> 

<?php 
include("nav.inc.php"); 
?>

</td> 

<td id="main" width="55%" valign="top"> 

<?php 
if (!isset($_REQUEST['content'])) 
include("ranger.inc.php"); 
else { $content = $_REQUEST['content']; $nextpage = $content . ".inc.php"; 
include($nextpage); } 
?>

</td> 

<td id="news" width="30%" valign="top"> 

<?php 
include("news.inc.php"); 
?>

</td> 
</tr> 
<tr> 

<td id="footer" colspan="3"> 

<div align="center"> 
<?php 
include("footer.inc.php"); 
?> </div>

</td>
</tr>

</table>

</body> </html>

 

Ranger.inc.php source file:

<h2 align="center">Videos</h2><br>
<?php

$con = mysql_connect("localhost", "name", "pass") or die('Sorry, could not connect to database server');

mysql_select_db("website", $con) or die('Sorry, could not connect to database');

$query = "SELECT weekid, link from ranger order by weekid";
$result = mysql_query($query) or die('Sorry, could not get videos at this time ');

if (mysql_num_rows($result) == 0) 
{ 
echo "<h3>Sorry, there are no videos posted at this time, please try back later.</h3>"; 
}
else 
{ 
while($row=mysql_fetch_array($result, MYSQL_ASSOC)) 
{ 
$weekid = $row['weekid'];
$link = $row['link'];

echo "<a href=\"ranger.php?content=showranger&id=$weekid\">$weekid</a><br>\n";

} 
} 
?>

ShowRanger.inc.php file

<?php
$con = mysql_connect("localhost", "name", "pass") or  die('Sorry, could not connect to server');

mysql_select_db("website", $con) or die('Sorry, could not connect to database');

$weekid = $_GET['id'];

$query = "SELECT link, weekid from ranger where weekid = $weekid";

$result = mysql_query($query) or die('Sorry, could not find video requested');  
$row = mysql_fetch_array($result, MYSQL_ASSOC) or die('No records retrieved'); 
$link = $row['link']; 
$description = $row['description']; 




?>

<object width="425" height="349">
<param name="movie" value="http://www.youtube.com/v/W0G3wzVyR00&hl=en&fs=1&rel=0&color1=0x5d1719&color2=0xcd311b&border=1">


<param name="allowscriptaccess" value="always">

<?php echo "<a href=$link>h</a><br>\n";?> 
</object>

 

The problem is that this makes it so someone has to click twice for the same file and then it still opens in a new window instead of embedding?

 

Thanks in advance.

 

Link to comment
Share on other sites

Sorry, I'm not sure what you mean?

 

You don't indent your code, which makes it really hard to keep track of.  You should really practice formatting your code nicely.  Anyway, what's actually wrong with the script?  I don't see any major issues with the quick glance over I gave it.

Link to comment
Share on other sites

Well, on the second page, you're outputting a link in the object tag instead of actually embedding it.  Look at the code that Youtube provides for embedding a video:

 

object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/oobDQ0vdm8M&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/oobDQ0vdm8M&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

 

Go to your video and just copy and paste the Embed code.

Link to comment
Share on other sites

What I was trying to get was that I have some thirty of these videos that all have to be on the site.  I was hoping that I could put all of the links into a database.  Then I wouldn't have to make 30 different html pages for each video.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.