brong112 Posted December 5, 2013 Share Posted December 5, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/ Share on other sites More sharing options...
requinix Posted December 5, 2013 Share Posted December 5, 2013 echo $idMissing 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 Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461431 Share on other sites More sharing options...
brong112 Posted December 5, 2013 Author Share Posted December 5, 2013 (edited) echo $idMissing 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 December 5, 2013 by brong112 Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461434 Share on other sites More sharing options...
requinix Posted December 5, 2013 Share Posted December 5, 2013 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 (\). Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461437 Share on other sites More sharing options...
brong112 Posted December 5, 2013 Author Share Posted December 5, 2013 Thanks, I'm getting closer? <?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">"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461438 Share on other sites More sharing options...
cyberRobot Posted December 6, 2013 Share Posted December 6, 2013 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'>"; Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461442 Share on other sites More sharing options...
brong112 Posted December 6, 2013 Author Share Posted December 6, 2013 (edited) 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 December 6, 2013 by brong112 Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461446 Share on other sites More sharing options...
plznty Posted December 6, 2013 Share Posted December 6, 2013 <?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'>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461453 Share on other sites More sharing options...
Solution cyberRobot Posted December 6, 2013 Solution Share Posted December 6, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/284570-please-help-with-echo-youtube-id-simple/#findComment-1461484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.