Jump to content


Photo

Syntax error--Adding HTML to PHP page


  • Please log in to reply
4 replies to this topic

#1 chris86

chris86
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 07 September 2006 - 06:18 PM

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.     
<img src="http://www.domain.com/uploads/Image/flags.jpg" alt="description of image"> 
</img>

What am I doing wrong?  Why the syntax error? 


#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 07 September 2006 - 06:21 PM

Get rid of the </img> tag...

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

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 chris86

chris86
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 07 September 2006 - 06:33 PM

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.


#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 07 September 2006 - 06:36 PM

Oh, if you're print from the php, you need to escape the quotes... try this:

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

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

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 chris86

chris86
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 07 September 2006 - 06:43 PM

That worked!  Fantastic, thanks. 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users