if and else if

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]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”>”;
}[/php]

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!!!

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.

Sponsor our Newsletter | Privacy Policy | Terms of Service