Jump to content

Please help with echo youtube id.. simple


Go to solution Solved by cyberRobot,

Recommended Posts

I used to have an acc at phpfreaks.. started coding again.  I'd appreciate some help cuz this is pissing me off..

	<?php
		$xml=simplexml_load_file("http://X/demo/statefarm/id.xml");
		$id = $xml->customid;
		echo $id
		
		?>

This works fine

	<?php
		$xml=simplexml_load_file("http://x.com/demo/statefarm/id.xml");
		$id = $xml->customid;
		echo $id
		
	echo	"<iframe src="$id" allowfullscreen="no" frameborder="0" height="125" width="182">" 
		
		?>

This dosen't.  I have tried every combination of syntax and google and I just get a blank page.  I'd appreciate some help, thanks.

Link to comment
https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/
Share on other sites

echo $id
Missing a semicolon. It works in the first one because it's the last statement within the <?php block. It's not the last statement in the second one.

 

echo	"
1. Missing a semicolon. Yes, last statement, but do it anyway.

2. Strings

echo $id
Missing a semicolon. It works in the first one because it's the last statement within the <?php block. It's not the last statement in the second one.

 

echo	"<iframe src="$id" allowfullscreen="no" frameborder="0" height="125" width="182">"
1. Missing a semicolon. Yes, last statement, but do it anyway.

2. Strings

 

 

 

thanks for the reply..

 

So I have this

	<?php
		$xml=simplexml_load_file("http://x.com/demo/statefarm/id.xml");
		$id = $xml->customid;

		
echo	"<iframe src="$id" allowfullscreen="no" frameborder="0" height="125" width="182">";
		
		?>

and 

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<message>
<customid>http://www.youtube.com/watch?v=gkTb9GP9lVI</customid>
</message>

here's my xml file

 

 

 

If I try and echo just the id, it works fine.  It only shows as a blank page when I'm putting it in the iframe.

 

Edit.. 

 

I can't find the right string.  I've tried over and over again.

Edited by brong112

They don't spell it out in the documentation for double-quoted strings, but they do for single-quoted.

Single quoted

 

The simplest way to specify a string is to enclose it in single quotes (the character ').

 

To specify a literal single quote, escape it with a backslash (\).

So the double-quoted string version would be

Double quoted

 

The next simplest way to specify a string is to enclose it in double quotes (the character ").

 

To specify a literal double quote, escape it with a backslash (\).

Thanks, I'm getting closer?  :sweat:

 

 

<?php
$xml=simplexml_load_file("http://x.com/demo/statefarm/id.xml");
$id = $xml->customid;




echo '<iframe src=' .$id . ' allowfullscreen="no" frameborder="0" height="125" width="182">';


?>
 

<?php
$xml=simplexml_load_file("http://x.com/demo/statefarm/id.xml");
$id = $xml->customid;




echo "<iframe src=\"$id/\" allowfullscreen="no" frameborder="0" height="125" width="182">";


?>

All of the quotes need to be escaped or changed. You could try

echo '<iframe src="' . $id . '" allowfullscreen="no" frameborder="0" height="125" width="182">';
 
Or
echo "<iframe src='$id' allowfullscreen='no' frameborder='0' height='125' width='182'>";

 

All of the quotes need to be escaped or changed. You could try

echo '<iframe src="' . $id . '" allowfullscreen="no" frameborder="0" height="125" width="182">';
 
Or
echo "<iframe src='$id' allowfullscreen='no' frameborder='0' height='125' width='182'>";

 

 

 

Before I put the variable in.. I can't even get it to show with just a youtube link?  I'm lost..

<?php

echo '<iframe src="http://www.youtube.com/watch?v=IWOA6F2s6Nc" allowfullscreen="no" frameborder="0" height="125" width="182">';
	

?>

or

<?php


echo "<iframe src=" . 'http://www.youtube.com/watch?v=IWOA6F2s6Nc' . " allowfullscreen="no" frameborder="0" height="125" width="182">";
	

?>

...screw this i'm playing video games.

Edited by brong112

    <?php
        $xml=simplexml_load_file("http://x.com/demo/statefarm/id.xml");
        $id = $xml->customid;
     
    echo    "<iframe src='$id' allowfullscreen='no' frameborder='0' height='125' width='182'>";
        
        ?>
  • Solution

For what it's worth, the embed code suggested by YouTube looks slightly different than what you have.

 

<iframe width="560" height="315" src="http://www.youtube.com/embed/nbp3Ra3Yp74" frameborder="0" allowfullscreen></iframe>

 

Also note that the website address is formatted differently than regular YouTube links.

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.