Jump to content

[SOLVED] Embedding Youtube Videos


Hughesy1986

Recommended Posts

Hi guys,

 

I am developing a cms for a clan web site. I am having trouble getting the video to load. I am using the object tags to load the video. Here is the script.

 

/* Clan CMS Team221 v1.0 Member System Control Panel */



// print the menu

?>
<a href="index.php?page=media&action=add">Add new media file</a> | <a href="index.php?page=media">View all media</a>
<?php

// set the action

$action = addslashes(strip_tags($_GET['action']));

// now we make the form to add

if ($action == "add" and !$_POST['add'])
	{
		// check the login

include("inc/login_check.php");
?>
<h1>Add new media file</h1>
<form action="" name="add" method="post">
<p>Media Title: <input type="text" name="title" class="form"/></p>
<p>Media Link: <input type="text" name="link" class="form"/></p>
<p>Category: <select name="category" class="form">
<option name="General">General</option>
<option name="Clan">Clan</option>
<option name="Random">Random</option>
</select></p>
<p>Comments:<br />
<textarea name="comments" rows="10" cols="50%" class="form"></textarea>
</p>
<p><input type="submit" name="add" value="Add new media file" class="form"/></p></form>

<?php
}
if ($_POST['add'])
	{
	$title = addslashes(strip_tags($_POST['title']));
	$link = addslashes(strip_tags($_POST['link']));
	$category = addslashes(strip_tags($_POST['category']));
	$comments = addslashes(strip_tags($_POST['comments']));

	// defaults

	$added = date("D d, M H:s");

	// error check

	if (!$title || !$link || !$category)
		{
		echo "<div class='error'>Please make sure all fields are complete</div>";
	}else{

		$query = "INSERT INTO media (comments, title, approved, link, added, category, author) VALUES ('$comments', '$title', '1', '$link', '$added', '$category', '$cms_logged')";
		mysql_query($query) or die (mysql_error());
		echo "<div class='error'>New media $title has been added, you will need to wait for a site admin to approve the media file, once this is complete your new file will be shown on the media page</div>";
		echo "<meta http-equiv='refresh' content='4; url=index.php?page=media'>";
}
}

if (!$action)
{
	$query = "SELECT * FROM media WHERE approved = '2' ORDER BY added DESC";
	$result = mysql_query($query) or die (mysql_error());
	$total = @mysql_num_rows($result);

	// error check

	if ($total == 0)
		{
		echo "<div class='error'>No media has been added yet</div>";
	}else{

	$i = 0;

	while($i < $total)
		{

		$title = mysql_result($result, $i, 'title');
		$added = mysql_result($result, $i, 'added');
		$link = mysql_result($result, $i, 'link');
		$id = mysql_result($result, $i, 'id');
		$category = mysql_result($result, $i, 'category');
		$author = mysql_result($result, $i, 'author');

?>
<div class="media_view">
<a href="index.php?page=media&action=show&id=<?php echo $id; ?>">View <?php echo $title; ?></a> Added on <strong><?php echo $added; ?></strong> by <strong><?php echo $author; ?></strong><br />
</div>

<?php
	$i++;
	}
}
}

// get the show action

if ($action == "show")
{
$id = addslashes(strip_tags($_GET['id']));

// error check

if (!$id)
	{
	echo "<div class='error'>Error in the ID Field</div>";
	echo "<meta http-equiv='refresh' content='2; url=index.php?page=media'>";
}else{

	$query = "SELECT * FROM media WHERE id = '$id'";
	$result = mysql_query($query) or die (mysql_error());
	$row = @mysql_fetch_array($result);

	if (!$row)
		{
		echo "<div class='error'>Error in the ID Field</div>";
		echo "<meta http-equiv='refresh' content='2; url=index.php?page=media'>";
	}else{

	$title = $row['title'];
	$link = $row['link'];
	$id = $row['id'];
	$author = $row['author'];
	$category = $row['category'];
	$comments = $row['comments'];
	$added = $row['added'];

?>
<div class="media_block">
<h1><?php echo $title; ?></h1>
Added by <strong><?php echo $author; ?></strong> on <strong><?php echo $added; ?></strong><br />
<object width="425" height="350"><param name="movie" value="<?php echo $link; ?>"></param><param name="wmode" value="transparent"></param><embed src="<?php echo $link; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><br />
Comments:<br />
<?php echo nl2br($comments); ?><br />
</div>

<?php
		}
	}
}

// set the default


?>

 

Heres the link

 

http://www.hughesy1986.com/team21/index.php?page=media&action=show&id=3

 

Also I made a test page with just the video and it works striaght away.

 

http://www.hughesy1986.com/team21/test

 

Does anyone have any experience with this, any help will be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/49057-solved-embedding-youtube-videos/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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