crmamx Posted February 27, 2011 Share Posted February 27, 2011 Would you please take a look at my code: http://bayarearcsociety.com/prototype/index.php and tell me why I cannot get an image to display. All I get is the alternate text. I am using Komodo editor and when I preview it there, it does display. Thanks Quote Link to comment Share on other sites More sharing options...
crmamx Posted February 27, 2011 Author Share Posted February 27, 2011 Elaboration: This one will not work yet the image is in the same file (content) as the program. <img src="flag_usa.gif" width="84" height="63" alt="usa flag image" /> This one works: <img src="http://bayarearcsociety.com/prototype/content/flag_usa.gif" /> I just can't figure it out. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 27, 2011 Share Posted February 27, 2011 For your index.php page in the prototype folder to display an image in prototype/content/ you would need to use - <img src="content/flag_usa.gif" width="84" height="63" alt="usa flag image" /> Edit: Alternatively, you can use a domain_root relative URL - <img src="/prototype/content/flag_usa.gif" /> Quote Link to comment Share on other sites More sharing options...
crmamx Posted February 27, 2011 Author Share Posted February 27, 2011 Thank you so much. It works. This has been driving me crazy. Could you please explain it to me. File structure: prototype----------index/php content---------maincontent.php, flag_usa.gif images Why is the reference from index.php and not maincontent.php? It seems I am calling it from maincontent.php. In my hundreds of other programs using just plain html if the program and image are in the same file, then I was using the correct src. Don't know if I will make it thru this redesign or not... :'( Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 27, 2011 Share Posted February 27, 2011 I going to assume that you are including the maincontent.php file into index.php? That includes the php code that is in maincontent.php ('content' just happens to be the path to where php can find the maincontent.php file at) into index.php. When the code is finally executed, the code that was included from maincontent.php is part of index.php and is being executed as part of index.php. Looking at this a slightly different way. The browser requested index.php. It is also the browser that requests the image in the src="..." attribute. The browser has no idea that maincontent.php even exits because the browser only sees the HTML that your index.php file outputs. Any relative URL's in an <img> tag are relative to the page they are on, in this case index.php. Quote Link to comment Share on other sites More sharing options...
crmamx Posted February 28, 2011 Author Share Posted February 28, 2011 You assume correctly. Wow! Most of this stuff is about as clear as the Mississippi River. But you just turned on a light bulb which will really help me understand some other stuff. Many thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.