Page 1 of 1
PHP in flash object
Posted: Tue Dec 28, 2010 5:10 am
by raamkum
Hi,
I have youtube video embedded to a php file. I keep uploading new youtube videos always because of this the link also keeps changing and also I need keep editing my php file always.
Instead what I thought was I could create a text file which will have the youtube link for the object and so the php file get the link from text and put in the required place accordingly.
To achieve the above idea below code is what I tried.
Code: Select all
<html>
<head>
<title>File read demo</title>
</head>
<body>
<?
$file = "/home/rambo/public_html/release/knot/text.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$a = $line;
print $a; (Just for Testing purpose)
}
<div align=center>
<object width="960" height="745"><param name="movie" value="<? print($line);?> &hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? print($line);?> &hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
</body>
</html>
It gives me a error stating:
Parse error: syntax error, unexpected '<' in /home/rambo/public_html/release/knot/test.php on line 14
I am not sure if
is correct in the code?
Please let me know the right syntax to solve this issue?
Awaiting your response!
Thanks!
Re: PHP in flash object
Posted: Tue Dec 28, 2010 5:39 am
by thecodewall
Re: PHP in flash object
Posted: Tue Dec 28, 2010 6:40 am
by raamkum
I get the same issue.
I added <?php ?>
It is not possible to add php in flash object is it?
Re: PHP in flash object
Posted: Tue Dec 28, 2010 4:59 pm
by danwguy
raamkum wrote:Hi,
I have youtube video embedded to a php file. I keep uploading new youtube videos always because of this the link also keeps changing and also I need keep editing my php file always.
Instead what I thought was I could create a text file which will have the youtube link for the object and so the php file get the link from text and put in the required place accordingly.
To achieve the above idea below code is what I tried.
Code: Select all
<html>
<head>
<title>File read demo</title>
</head>
<body>
<?
$file = "/home/rambo/public_html/release/knot/text.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$a = $line;
print $a; (Just for Testing purpose)
}
<div align=center>
<object width="960" height="745"><param name="movie" value="<? print($line);?> &hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? print($line);?> &hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
</body>
</html>
It gives me a error stating:
Parse error: syntax error, unexpected '<' in /home/rambo/public_html/release/knot/test.php on line 14
I am not sure if
is correct in the code?
Please let me know the right syntax to solve this issue?
Awaiting your response!
Thanks!
He is saying that where you are saying print $a; (just for testing) then you have } but you need to end your php with ?> before you can put in html coding so it should look like this...
Code: Select all
<html>
<head>
<title>File read demo</title>
</head>
<body>
<?
$file = "/home/rambo/public_html/release/knot/text.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$a = $line;
print $a; (Just for Testing purpose)
}
?>
<object width="960" height="745"><param name="movie" value="<? print($line);?> &hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? print($line);?> &hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
</body>
</html>
and I would use <?php echo $line; ?> instead, just my preference but that's how I do it.
Re: PHP in flash object
Posted: Tue Dec 28, 2010 9:15 pm
by raamkum
This is what I tried... as per your advice. I get the print of the text in text file... and then Blank. The text has nothing but a link for youtube.
Code: Select all
<html>
<head>
<title>File read demo</title>
</head>
<body>
<?
$file = "/home/rambo/public_html/release/knot/text.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$a = $line;
print $a;
}
?>
<div>
<object width="960" height="745"><param name="movie" value="<?php print $line; ?>&hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? print $line;?>&hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
<div>
<object width="960" height="745"><param name="movie" value="<?php echo $line; ?>&hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? echo $line;?> &hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
<div>
<object width="960" height="745"><param name="movie" value="<?php print ($line); ?>&hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? print ($line);?>&hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
<div>
<object width="960" height="745"><param name="movie" value="<?php echo ($line); ?>&hl=en_US&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<? echo ($line);?>&hl=en_US&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="670" height="600"></embed></object>
</div>
<?php echo $line; ?>
<?php print $line; ?>
<?php echo ($line); ?>
<?php print ($line); ?>
</body>
</html>
I put <? print($line);?> and also <? echo($line);?> above </body> I didn't get anything. So I can say print $line or echo $line is not getting any value after ?>... What could be wrong here? Anybody tried this?
Re: PHP in flash object
Posted: Tue Dec 28, 2010 11:20 pm
by McInfo
raamkum wrote:I get the print of the text in text file... and then Blank. [...] What could be wrong here?
Understand why this loop terminates (which implies that it's not an infinite loop) and you will know why $line is blank.
thecodewall wrote:In php 5 php is now required in <?
False.
Re: PHP in flash object
Posted: Tue Dec 28, 2010 11:39 pm
by raamkum
Thanks for the reply McInfo.
Sorry but I didn't understand what you were saying?
The text in the text file. I showing correctly for the print command but doesn't insert the same thin in Flash Object after " ?> "? I figured that the variable is not working because when I gave the print command above </body> in the code it didn't print anything except the blank page.
You can give a try on with the code and you will know what I am saying?
Let me know if I made any sense!
Thanks!
Re: PHP in flash object
Posted: Wed Dec 29, 2010 2:21 am
by McInfo
You know that fgets() will retrieve a line from the text file and that the returned string will be assigned to the $line variable. You may also know that, if there are two lines in the file, this while() structure will get both lines. If both lines are strings and the loop continues after getting the first line, wouldn't you expect the loop to continue after getting the second line?
So, ask yourself, "Why does the loop terminate?"
The answer is that the loop will evaluate its conditional expression once more than the number of lines in the file. When fgets() encounters the end of the text file, it returns
false. That false value is assigned to the $line variable; then the assignment expression is evaluated by while(). Because the expression is false, the loop terminates. After the loop, $line still holds false, not a line from the file.
Re: PHP in flash object
Posted: Wed Dec 29, 2010 4:26 am
by raamkum
Great. Thanks McInfo. This is theory helped to solve my issue.
Instead of $line I put $a in print in flash object.
BTW: <? or <?php or <? echo or <? print or <?php echo or <?php print worked just fine!
Thanks for the help guys!