Author Topic: if and else if  (Read 129 times)

waveyd

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
if and else if
« on: January 27, 2012, 03:30:21 PM »
I'm new to php and msql, but can someone explain to me why this isn't working, or what I need to do to make it work?

Basically, I'm embedding YouTube or Vimeo videos, and I'm just having my database pick off the code of standard youtube (http://www.youtube.com/watch?v=Zgfi7wnGZlE) and vimeo (http://vimeo.com/9038552) and rearranging the URL so that it will pop up.

All I am referencing in mysql is two fields: one for the code ("Zgfi7wnGZlE" or "9038552" and one for the video_type that's either "YouTube" or "Vimeo"

PHP Code: [Select]
if($row['video_type']='YouTube'
{echo 
"href=\"http://www.youtube.com/v/";}
elseif(
$row['video_type']='Vimeo')
{echo 
"href=\"http://player.vimeo.com/video/";}
  echo 
$row['code'];
  echo 
"?title=0&byline=0&portrait=0&color=ffffff&autoplay=1\">";
}


Depending on which video_type, the result is either

http://www.youtube.com/v/Zgfi7wnGZlE/?title=0&byline=0&portrait=0&color=ffffff&autoplay=1

or

http://player.vimeo.com/video/9038552/?title=0&byline=0&portrait=0&color=ffffff&autoplay=1

But it's always putting in the YouTube URL, and never the vimeo one, even though the video_type is clearly "Vimeo" in my mysql database...


Thanks for your help!!!
« Last Edit: January 28, 2012, 08:54:31 AM by jSherz »

waveyd

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: if and else if
« Reply #1 on: January 27, 2012, 04:22:33 PM »
I think I fixed by adding double equal signs ==  and putting "YouTube" and "Vimeo" in double quotes in the if/else if lines...

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: if and else if
« Reply #2 on: January 28, 2012, 08:55:01 AM »
I think I fixed by adding double equal signs ==  and putting "YouTube" and "Vimeo" in double quotes in the if/else if lines...

The double quotes wouldn't be required, but the == would have been what fixed it.
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.