Jump to content

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.