Dear All,

I am new to PHP. I would like to include video (Flash Videos) in the website using PHP. Can u please help by giving the code.

Saji

Recommended Answers

All 6 Replies

Dear All,

I am new to PHP. I would like to include video (Flash Videos) in the website using PHP. Can u please help by giving the code.

Saji

Here is code from a previous project of mine. Use as much or as little as you want. The function I have included really only uses 5 fields:
videoID
status
title
caption
embed_code

MySQL Videos Table

DROP TABLE IF EXISTS `videos`;
CREATE TABLE `videos` (
  `videoID` mediumint(8) unsigned NOT NULL auto_increment,
  `status` enum('Active','Disabled') NOT NULL default 'Active',
  `title` varchar(35) default NULL,
  `caption` text,
  `category` varchar(35) default NULL,
  `filename` varchar(35) default NULL,
  `embed_code` text,
  `video_date` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`videoID`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

-- 
-- Dumping data for table `videos`
-- 

INSERT INTO `videos` (`videoID`, `status`, `title`, `caption`, `category`, `filename`, `embed_code`, `video_date`) VALUES (1, 'Active', 'Lonely Angel', 'Kid Theodore''s Lonely Angel music video', 'www.kidtheodore.com', NULL, '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/l5os6oII8Hk"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/l5os6oII8Hk" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', '2007-10-25')

PHP function to call the information from the database.
You would need to connect to your database first.

function getVideo($vid) {
//$vid = a videoID in the table videos
	$query = "SELECT * FROM videos WHERE status = 'Active' AND videoID = '$vid'"; 
	$result = mysql_query($query); 
  	  if (mysql_num_rows($result) > 0) {		
		$row = mysql_fetch_array( $result );
			$output .= "
			<h2>$row[title]</h2>
			$row[embed_code]<br>
			$row[caption]
			";
	  } else {
	  $output = "No video was found at this time.<br> Please check back soon.<br>";
	  }

			
return $output;
} //usage //echo getVideo($vid);

Thank you very much . Is working and solved my problem.

Saji

Thank you very much . Is working and solved my problem.

Saji

The code worked fine with youtube video. When I replaced with my video it is a FLV file and its name is pv160308.flv, it is not working.

What I did ..

replaced the value="http://www.youtube.com/v/l5os6oII8Hk" and
src=" http://www.youtube.com/v/l5os6oII8Hk"
with local
value="pv160308.flv" and
src= "pv160308.flv".

When executed . no display is coming.

Could u pl. help

Saji

The code worked fine with youtube video. When I replaced with my video it is a FLV file and its name is pv160308.flv, it is not working.

What I did ..

replaced the value="http://www.youtube.com/v/l5os6oII8Hk" and
src=" http://www.youtube.com/v/l5os6oII8Hk"
with local
value="pv160308.flv" and
src= "pv160308.flv".

When executed . no display is coming.

Could u pl. help

Saji

I guess I misunderstood the question. You need to create an Adobe Flash FLV player... which would be a SWF file that has controls (play pause rewind) You could create this file to use a FLASHVAR to name the FLV file that you want to load in.
Ex:

src= "flvplayer.swf?video=pv160308.flv"

There would be a variable in your flash file called 'video' that it would load onto the scene.

you can try JW flash player.It's free and easy to use.

Dear All,

I am new one to PHP. I would like to include video (Flash Videos) like .flv file in the website using PHP. Can u please help me by giving the code and instructions.

Regards!
MalikAamir

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.