Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-23-2011, 06:00 AM Checking for a value
Novice Talker

Posts: 14
Location: UK
Trades: 0
Hi All,

Bit of a coding error - I'm not that experienced and self-taught from messing around with PHP so I think I've got into some bad habits and thats what's causing the problem!

My issue is; at present I've got a SQL database with a list of videos all hosted onsite, however I've recently added some videos which are hosted offsite on youtube... What I'd like to do is pull videos from the internal source but UNLESS a youtube selection has been made...

I thought the easiest way to do this would be to add two fields into my database, a value that is yes or no (to see if their is a youtube link) and the embed code to be displayed if the value is yes.

My code looks like this:
PHP Code:
<?php 

$video 
$_GET['video'];

?>
<?php
$data 
mysql_query("SELECT * FROM video WHERE ID = '{$video}' ORDER BY added DESC") or die(mysql_error());
mysql_real_escape_string($video);
while(
$info mysql_fetch_array$data )) if ({$info['ytembed']} = yes) { 
echo 
"<div class='video-container'>";
echo 
"{$info['embedcode']}";
echo 
"<div class='video-title'>{$info['title']}</div>";
echo 
"<div class='video-subtitle'>{$info['subtitle']}</div>";
echo 
"</div>";
} else {
echo 
"<div class='video-container'>";
echo 
"<div class=\"video-js-box\">";
echo 
"<video class=\"video-js\" width=\"640\" height=\"360\" controls preload poster=\"../{$info['still']}\">
<source src=\"../
{$info['qtmobile']}\" type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"' />";
echo 
" <object id=\"flash_fallback_1\" class=\"vjs-flash-fallback\" width=\"640\" height=\"360\" type=\"application/x-shockwave-flash\" 
data=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\">
<param name=\"movie\" value=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\" />
<param name=\"allowfullscreen\" value=\"true\" />
<param name=\"flashvars\" 
value='config={\"playlist\":[\"http://www.website.com/
{$info['qtmobile']}\", {\"url\": \"http://www.jameshenry.info/{$info['qtmobile']}\",\"autoPlay\":false,\"autoBuffering\":true}]}' />
<img src=\"../
{$info['still']}\" width=\"640\" height=\"360\" alt=\"Poster Image\" 
title=\"No video playback capabilities.\" />
</object>"
;
echo 
"</video></div>";
echo 
"<div class='video-title'>{$info['title']}</div>";
echo 
"<div class='video-subtitle'>{$info['subtitle']}</div>";
echo 
"<br>";
echo 
"<div class='back'><a href=\"./\">&laquo;back</a></div>";
echo 
"</div>";
}
?>
I'm getting a syntax error on line 37 at the moment, so I'm guessing my error is with this "while($info = mysql_fetch_array( $data )) if ({$info['ytembed']} = yes) { "

Any help sorting this issue out would be appreciated! Any ideas?
hj8ag is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-23-2011, 07:35 AM Re: Checking for a value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
why don't you simply check if "youtube" is in the string returned from the database?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-23-2011, 10:10 AM Re: Checking for a value
Novice Talker

Posts: 14
Location: UK
Trades: 0
The string that is being passed/pulled to the page is a numerical value at present, each video has a numerical identifier which is used.
hj8ag is offline
Reply With Quote
View Public Profile
 
Old 05-23-2011, 10:18 AM Re: Checking for a value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
In that case a lookup table of of the youtube IDs would be less wasteful than an extra column, would would be essentially redundant data.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-23-2011, 10:32 AM Re: Checking for a value
Novice Talker

Posts: 14
Location: UK
Trades: 0
Quote:
Originally Posted by chrishirst View Post
In that case a lookup table of of the youtube IDs would be less wasteful than an extra column, would would be essentially redundant data.
Sounds like it might be a plan! Going to Google lookup tables now
hj8ag is offline
Reply With Quote
View Public Profile
 
Old 05-23-2011, 01:30 PM Re: Checking for a value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The process is called "Normalisation", have a look at First Normal Form (1NF) database schemas also called "Minimal Form"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Checking for a value
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23609 seconds with 12 queries