0

Hello,

Somehow this is not working. I tried pretty much everything.
I am also very new to PHP, but i made a nice CMS. Now I am making a website with some random flash-videos every time you refresh. This is what i got so far:

<html>
<head>
<title>Sydcul.com</title>
</head>
<body>
<h1>Sydcul.com</h1>
<h2>Warning: flashing images!</h2>
<p>It would be fun to turn on your sound.</p>
<?php
echo('This is visible, all stuff below is not. So the closing tags are not visible too.');
echo('<embed src="flash/' . rand(1, 5) . '.swf" type="application/x-shockwave-flash" width="320" height="240></embed>');
?>
</body>
</html>

I am not really sure how to implement HTML in PHP, so it is something really small i guess.

5
Contributors
4
Replies
8
Views
4 Years
Discussion Span
Last Post by bradly.spicer
0

Try with double quotes, use statement given below, Php string is in double quote and html element values are in single quote

echo("<embed src='flash/" . rand(1, 5) . ".swf' type='application/x-shockwave-flash' width='320' height='240'></embed>");
1

You have done it OK, only a double quote (as part of html attribute value) is missing after 240.

echo('<embed src="flash/' . rand(1, 5) . '.swf" type="application/x-shockwave-flash" width="320" height="240"></embed>');
1

why don't you try like this (replace your php code with bellow code it works perfectly)

<?php

echo('This is visible, all stuff below is not. So the closing tags are not visible too.');

?>
<embed src="flash/<? echo rand(1, 5);?>.swf" type="application/x-shockwave-flash" width="320" height="240"></embed>


<?
  // remaining your code 
?>

Edited by radhakrishna.p: giving clarity on the solution

0

Going to explain the above post more.

basically all your doing is stopping your php, doing html and re-entering php. PHP like many languages has the ability to jump in and out using tags

<?php echo'//Functionhere' ?>

As long as you open and close properly it's fine. You can also echo HTML :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.