Forum Moderators: coopster

Message Too Old, No Replies

Output HTML with PHP

         

ineedmoney

1:41 pm on May 22, 2006 (gmt 0)

10+ Year Member



Hi, I'm having a little strouble with my PHP sytax (I think) Anyhow, I am working on a generator that will allow my visitors to select an image in a form, then when they submit, it will take them to a page that displays the HTML code they need to copy and paste. The problem I am having is that I can't echo the HTML code. Does anyone know how to Echo HTML? this is the code I am using:

if ($file == "one"){
echo "<embed src="$url" width="$width" height="$height" type="application/x-shockwave-flash"></embed>";

Let me know if you need anything else. All help would be appreciated. Thanks!

dreamcatcher

1:46 pm on May 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two ways you can do it:

Enclose your echo in apostrophes:

echo '<embed src="$url" width="$width" height="$height" type="application/x-shockwave-flash"></embed>';

or escape the quotes:

echo "<embed src=\"$url\" width=\"$width\" height=\"$height\" type=\"application/x-shockwave-flash\"></embed>";

dc

ineedmoney

2:05 pm on May 22, 2006 (gmt 0)

10+ Year Member



dc

Thanks for the help, when I use the code you provide I get this error

Parse error: parse error, unexpected $ in /homepages/20/d161977859/htdocs/isdproductions/addlink.php on line 70

Line 70 is after my </html> and contains no code?

This is very confusing to me

Full Code

<?php

$url = $_POST['url'];
$file = $_POST['file'];
$width = $_POST['width'];
$height = $_POST['height'];

if ($file == "one"){
echo "<embed src=\"$url\" width=\"$width\" height=\"$height\" type=\"application/x-shockwave-flash\"></embed>";

?>

[edited by: ineedmoney at 2:08 pm (utc) on May 22, 2006]

Habtom

2:07 pm on May 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The solution provided by dreamcather is fine. You just have got to look at the rest of your codes.

Habtom

ineedmoney

2:08 pm on May 22, 2006 (gmt 0)

10+ Year Member



Full Code

<?php

$url = $_POST['url'];
$file = $_POST['file'];
$width = $_POST['width'];
$height = $_POST['height'];

if ($file == "one"){
echo "<embed src=\"$url\" width=\"$width\" height=\"$height\" type=\"application/x-shockwave-flash\"></embed>";

?>

dreamcatcher

2:20 pm on May 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your if statement has no closing brace.

Should be:


if ($file == "one"){
echo "<embed src=\"$url\" width=\"$width\" height=\"$height\" type=\"application/x-shockwave-flash\"></embed>";
}

dc

ineedmoney

2:24 pm on May 22, 2006 (gmt 0)

10+ Year Member



that would do it, I feel like an idiot...

Thankyou