Muteking Posted September 19, 2013 Share Posted September 19, 2013 My first post, here. I'm a newbie in PHP. I'm stuck in a simple problem I have my index.php in the base folder which includes right.php. This right.php has to load an image (base folder/img) but it's in another folder called 'includes'(base folder/includes). I cannot figure out what value I have to assign to my $baseUrl variable, in order to jump back to the base folder. Here is right.php: <? $baseUrl = "../" ;?><div class = "right"><h1> Rifrazione news </h1><hr><?echo '<img src="'.$baseUrl.'/img/face.png" width="200" alt="news"/>';?><p class = "rightp">bla bla </p><br></div><!--end of right--> Link to comment https://forums.phpfreaks.com/topic/282277-loading-image-from-php-include/ Share on other sites More sharing options...
requinix Posted September 19, 2013 Share Posted September 19, 2013 When dealing with URLs in your HTML, the only(ish) thing that matters is what shows up in the address bar of the browser. The easiest way to not care about that is to use absolute URLs: a leading slash. If the image is in the includes/ folder of your website (and your website isn't in a subfolder like http://www.example.com/subfolder) then Link to comment https://forums.phpfreaks.com/topic/282277-loading-image-from-php-include/#findComment-1450215 Share on other sites More sharing options...
Muteking Posted September 19, 2013 Author Share Posted September 19, 2013 The problem is that the image in not in the includes folder. Here's the effect, anyway, even if I try alernate code with leading slash <div class = "right"><h1> News </h1><hr><?echo '<img src="/img/face.png" width="200" alt="News"/>';?><p class = "rightp"> Bla blalalal</p><br></div><!--end of right--> Link to comment https://forums.phpfreaks.com/topic/282277-loading-image-from-php-include/#findComment-1450221 Share on other sites More sharing options...
mac_gyver Posted September 19, 2013 Share Posted September 19, 2013 you need to always use the full opening php tag - <?php Link to comment https://forums.phpfreaks.com/topic/282277-loading-image-from-php-include/#findComment-1450227 Share on other sites More sharing options...
Muteking Posted September 19, 2013 Author Share Posted September 19, 2013 Thanks mac_gyver. Link to comment https://forums.phpfreaks.com/topic/282277-loading-image-from-php-include/#findComment-1450229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.