Jump to content

Parse error: syntax error, unexpected T_ELSEIF


strago

Recommended Posts

  $download_link = $tube->get('http://www.youtube.com/watch?v='.$_GET['v']);
  $download_link2 = $tube->get($_GET['v']);

if($download_link); {
echo <<< END
<BR>2. Right click <a href="$download_link">this link</a>.
END;
}
if(!($download_link2)); {
echo <<< END
<BR>2. Right click <a href="$download_link2">this link</a>.
END;
}
elseif {
echo <<< END
    <P>Error locating download URL.
END;
}
echo <<< END
  <center><H1>Last 20 Downloads</H1></center>
END;
  include('downloads.html');
  }
?>

 

The

elseif {
echo <<< END
    <P>Error locating download URL.
END;
}

 

part is spiting out

 

Parse error: syntax error, unexpected T_ELSEIF in /public_html/index.php  on line 59

 

 

If some one enters for example '9lp0IWv8QZY' in the form, only the first if should show up. If they enter hxxp://www.youtube.com/watch?v=9lp0IWv8QZY in the form, then just the second if should show up.

 

Then if nether one of those works, then the ELSEIF error needs to come up.

Link to comment
Share on other sites

for a start I'm not a huge fan of the syntax you're using, secondly, I thought it was a colon rather than a semi colon after the if statement, and thirdly you need to put a conditional after your elseif. It needs to be elseif ($a == $b). If you wanted the elseif to be a default incase the if statement wasn't true then you should just do else. I would change your syntax to:

 

  $download_link = $tube->get('http://www.youtube.com/watch?v='.$_GET['v']);
  $download_link2 = $tube->get($_GET['v']);

if($download_link) {
   echo '2. Right click <a href='.$download_link.'>this link</a>.';
}

if(!($download_link2)) {
   echo '<BR>2. Right click <a href='.$download_link2.'>this link</a>.';
} else if {
   echo '<P>Error locating download URL.</p>';
} else {
   echo '<center><H1>Last 20 Downloads</H1></center>';
   include('downloads.html');
}
?>

 

This is much clearer for people to read and understand in my opinion. If you don't agree then that's fine, I'd try the suggestions I made above to get your code working.

Link to comment
Share on other sites

Thats a heredoc. If you want to echo it out then do so but a heredoc is

elseif {

$html = <<< END

    <P>Error locating download URL.

END;

}

the if statements dont need terminating.

Your use of double quotes inside of single quotes will not output the value of the var, use

"this is a \"$correct\" use of quotes";

 

 

HTH

Teamatomic

Link to comment
Share on other sites

Thats a heredoc. If you want to echo it out then do so but a heredoc is

elseif {

$html = <<< END

    <P>Error locating download URL.

END;

}

the if statements dont need terminating.

Your use of double quotes inside of single quotes will not output the value of the var, use

"this is a \"$correct\" use of quotes";

 

 

HTH

Teamatomic

 

that was just me being lazy and not checking my code... dammit...

Link to comment
Share on other sites

Thanks. I'm actually the epitome of a php n00bie. (Think of a third grader trying to figure out algebra!) I just wanted it working and didn't care how I could get it to work!

 

When I found these forums, it was like I found heaven!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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