Welcome Guest, Not a member yet? Register   Sign In
base_url() stops executing
#1

[eluser]Maglok[/eluser]
I have used the base_url() in a lot of view stuff already and it usually works. Lately though it has been giving me a problem.

My config.php reads:

Code:
$config['base_url'] = "http://www.someurl.com/somedir/";

Then I tried referencing a stylesheet like this:

Code:
<link rel="stylesheet" href="<?php echo base_url(); ?>css/style.css" type="text/css" media="screen" />

That actually kills the generation of the site like so:

Code:
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="

When I then echo base_url() anywhere it stops when it gets to that point.

Something is fishy and I don't know what. I have had it work on this host before. I can also load the CSS in the example if I just create the url myself instead of using base_url(), but that would be quite sloppy.
#2

[eluser]gtech[/eluser]
humm base_url is a pretty simple function.. have you autoloaded the helper?

autoload.php
Code:
$autoload['helper'] = array('url');
#3

[eluser]Dam1an[/eluser]
So when did it last work and what did you do before you noticed it stopped working?

base_url return config->slash_item which can return false if the item doesn't exist in the config array for some reason, so test to see if this is a case

Code:
if(base_url() === FALSE) {
  echo 'Something is seriously wrong';
} else {
  echo 'Hmm... I'm confused';
}
#4

[eluser]Maglok[/eluser]
How very odd, I am pretty sure I have never needed to load the helper to get it to work. Can't argue with the code though. Mabye in another project it was already in the autoload, odd indeed.

It's stuff like this that a quick glance from someone else can easily fix. It was indeed the helper that needed autoloading. Simple thing, it is indeed monday morning.
#5

[eluser]Dam1an[/eluser]
Oh, I assumed you had it working on this project, and I assumed you wouldn't have un autoloaded it to break it lol
#6

[eluser]gtech[/eluser]
ignore, reply.. i was waffling.. anyway glad it works.
#7

[eluser]Maglok[/eluser]
@Dam1an: I had it working on this application. I just dug into the code and it seems I manually loaded the url helper for a certain function then during development somehow removed it.




Theme © iAndrew 2016 - Forum software by © MyBB