Jump to content

Archived

This topic is now archived and is closed to further replies.

chris86

Syntax error--Adding HTML to PHP page

Recommended Posts

I'm trying to add an image (via HTML) to a PHP page.  I get a syntax error when I insert the following HTML code into the PHP page.  Below is the HTML code I inserted.     
[code]
<img src="http://www.domain.com/uploads/Image/flags.jpg" alt="description of image">
</img>
[/code]

What am I doing wrong?  Why the syntax error? 

Share this post


Link to post
Share on other sites
Get rid of the </img> tag...

Try:
[code]
<img src="http://www.domain.com/uploads/Image/flags.jpg" alt="description of image" />
[/code]

Regards
Rich

Share this post


Link to post
Share on other sites
Thanks.  I killed the </img> tag, and inserted the code you suggested.  Unfortunately, I'm still getting a syntax error on line 2.  Looks like PHP doesn't like the "<" sign. 

Error message reads...

syntax error, unexpected '<' 

So, I deleted the <> tags and now I'm getting a syntax error that reads, "unexpected T_STRING".

Any other suggestions?  I'm just trying to add an image.

Share this post


Link to post
Share on other sites
Oh, if you're print from the php, you need to escape the quotes... try this:

[code=php:0]
<?php
echo "<img src=\"http://www.domain.com/uploads/Image/flags.jpg\" alt=\"description of image\">";
?>
[/code]

If that doesn't work, post the code you have.

Regards
Rich

Share this post


Link to post
Share on other sites

×

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.