Jump to content

Syntax error--Adding HTML to PHP page


chris86

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? 
Link to comment
https://forums.phpfreaks.com/topic/20036-syntax-error-adding-html-to-php-page/
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.
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

Archived

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

×
×
  • Create New...

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.