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--> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Muteking Posted September 19, 2013 Author Share Posted September 19, 2013 (edited) 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--> Edited September 19, 2013 by Muteking Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted September 19, 2013 Solution Share Posted September 19, 2013 you need to always use the full opening php tag - <?php Quote Link to comment Share on other sites More sharing options...
Muteking Posted September 19, 2013 Author Share Posted September 19, 2013 Thanks mac_gyver. 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.