Jump to content
Sign in to follow this  
Booga

[solved] Images in php file included in HTML site.

Recommended Posts

Hello all be gentle I am an utter noob.I am using a php page included in my html site for the navbar and footer.All was well until I added an image to the navbar and now it only displays the alt text for the image and not the image itself.The image (TheShirePostMint.jpg) is saved with all the other site images and uploaded to server.Navbar code.

<html><head><meta id="_moz_html_fragment"></head><body><div id="navbar"><table style="text-align: left; width: 178px; height: 440px;" border="0"cellpadding="2" cellspacing="2"><tbody><tr><td align="undefined" valign="undefined">*TheShire Post*</td></tr><tr><td align="undefined" valign="undefined">  <a href="index.shtml">Home</a><br><br>   <a href="history.html">History</a><br></td></tr><tr><td align="center" valign="middle"><imgstyle="width: 208px; height: 32px;" alt="*The Shire Post Mint*"src="TheShirePostMint.jpg"> </td></tr><tr><td align="undefined" valign="undefined">  <a href="shirecoins.shtml">Coinsof the Shire</a><br><br>   Coins of other Realms</td></tr><tr><td align="undefined" valign="undefined">*TheShire Post Office*</td></tr><tr><td align="undefined" valign="undefined">  Shire Post Stamps<br><br>   Shire Post Franks</td></tr><tr><td style="height: 8px;"><br></td></tr><tr><td align="undefined" valign="undefined">*Links*</td></tr><tr><td align="undefined" valign="undefined">  <a target="_blank" href="http://www.glyphweb.com/ARDA/">TheEncyclopedia of Arda</a><br><br>   <a href="http://www.shirepost.com/" target="_blank">TheShire Post</a></td></tr><tr><td style="height: 10px;"><br></td></tr><tr><td align="undefined" valign="undefined">*WithThanks*</td></tr><tr><td align="undefined" valign="undefined">  <a target="_blank" href="http://www.tolkienshop.com/index.html">TheTolkien Shop</a><br>   Maturin492(at)verizon.net</td></tr><tr><td style="height: 8px;"><br></td></tr><tr><td align="undefined" valign="undefined">*Contact Me*</td></tr><tr><td align="undefined" valign="undefined"> booga23(at)gmail.com</td></tr></tbody></table></div></body></html>

How it appears in KomposerNavbar-image_01.jpgCode for inclusion into html.

<!--START OF THE NAVBAR--><div id="navbar"><?php include("navbar.php"); ?> <br></div><!--END OF THE NAVBAR--> </td>

Any help much appreciated.

Edited by Booga

Share this post


Link to post
Share on other sites

I'm confused. Is the first snippet the contents of navbar.php? Does it have any php code in it? Why not just include it as an HTML file? And regardless of what file type it is, you should be including all new <html>, <head> any <body>. I also don't see any image tags in there. I'm having a hard time putting it all together based on what you posted.

Share this post


Link to post
Share on other sites
<td align="center" valign="middle"><imgstyle="width: 208px; height: 32px;" alt="*The Shire Post Mint*"src="TheShirePostMint.jpg"> </td></tr>
You have the syntax all wrong. I am assuming the src and alt you have here is intended for an image tag like:
<img alt="The Shire Post Mint" src="TheShirePostMint.jpg"/>

If you put an src in style then it must point to a stylesheet file.

Share this post


Link to post
Share on other sites
I'm confused. Is the first snippet the contents of navbar.php? Does it have any php code in it? Why not just include it as an HTML file? And regardless of what file type it is, you should be including all new <html>, <head> any <body>. I also don't see any image tags in there. I'm having a hard time putting it all together based on what you posted.
Yes it is the content of the navbar and yes you are right, I didn't realize you could include html. I just read the leason on icluding php and assumed that is what you have to do.
You have the syntax all wrong. I am assuming the src and alt you have here is intended for an image tag like:
<img alt="The Shire Post Mint" src="TheShirePostMint.jpg"/>

If you put an src in style then it must point to a stylesheet file.

Thanks I think I know what the problem is.

Share this post


Link to post
Share on other sites
You have the syntax all wrong. I am assuming the src and alt you have here is intended for an image tag like:
<img alt="The Shire Post Mint" src="TheShirePostMint.jpg"/>

If you put an src in style then it must point to a stylesheet file.

huh? an image can have inline styles as written, as well as src. the src in this case is the path to the image.
<img style="width: 208px; height: 32px;" alt="*The Shire Post Mint*" src="TheShirePostMint.jpg">

there's nothing wrong with that syntax.the question should be is the path to the image correct? Is it in the same folder as the HTML? For includes and images, you may want to consider using paths relative to the webroot as opposed to the document, just to be on the safe side. i.e.

<img src="/images/image.jpg">

again, if you are including content into an HTML document, you shouldn't have those extra <html> <body> etc tags since they will be duplicated and cause rendering/validation errors.

Edited by thescientist

Share this post


Link to post
Share on other sites

Crap I didn't see the open "img" tag I assumed it was an open "style" tag. That syntax is correct, adding to what thescientist said make sure that you use the filename exactly as it is stored on the system.

Share this post


Link to post
Share on other sites
huh? an image can have inline styles as written, as well as src. the src in this case is the path to the image.
<img style="width: 208px; height: 32px;" alt="*The Shire Post Mint*" src="TheShirePostMint.jpg">

there's nothing wrong with that syntax.the question should be is the path to the image correct? Is it in the same folder as the HTML? For includes and images, you may want to consider using paths relative to the webroot as opposed to the document, just to be on the safe side. i.e.

<img src="/images/image.jpg">

again, if you are including content into an HTML document, you shouldn't have those extra <html> <body> etc tags since they will be duplicated and cause rendering/validation errors.

Yes thank you that was Komposer sticking its nose in. I had previously removed all of that in Notebook but must have saved it again after opening it with Komposer. I shall remove them.The image is with all the other files in the public folder. I haven't made any sub folders but I will do now and add all move all the images to that folder and redirect the links, for good house keeping.Thanks for the help.
Crap I didn't see the open "img" tag I assumed it was an open "style" tag. That syntax is correct, adding to what thescientist said make sure that you use the filename exactly as it is stored on the system.
Thanks will do.

Share this post


Link to post
Share on other sites

it should all be fine as long as your paths are correct.

Share this post


Link to post
Share on other sites

Bingo!Thanks thescientist I just changed the file extension to html and it worked.

	  <!--START OF THE NAVBAR-->      <div id="navbar">	  <?php include ("navbar.html"); ?>      </div>	  	<!--END OF THE NAVBAR--> 

Navbar-image_02.jpg

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...