Welcome Guest, Not a member yet? Register   Sign In
base_url() doesn't work

hi guys i'm new to codeigniter. So i'm kinda following the tutorials. I have configured base url in my config file but when i go to use the variable it does not work. Any reasons?

Also php seems to die when it's embedded in a [removed] tag.

I'm running locally on my hard drive with apache 2.2 and php5.

You need to specify your question a little more. How does your config.php look? How do you print it, the function etc. Anyways, it could be your server, but I doubt it.

this is what i have inside my config.php file.

$config['base_url'] = "c:/web";


I'm gonna go ahead and guess it's my server but i've got no clue what to change to make it work.

my question is this...

why doesn't base_url() function display "c:/web" in this case? what do i need to change to get it working?

I'm pretty sure it's my server or php because i have another variable defined for my page title and it doesn't echo that out. It seems PHP will only echo a variable that is contained within the same page.

for instance i have a variable defined for $page_title inside file index.php

inside index.php i am including "page_header.php"

my title will not echo within page_header.php. before using codeigniter it was working fine on my website.

Yes, okay, that's probably why it doesn't work. If you got a server running on your computer, you might need to do it like this. Type in "localhost" in your browser and find the folder where CI is located. Copy that URL into your base_url in config.php

An example could be my server, I got a WAMP server running. Whenever I type localhost in my browser it shows my index.php in my "www" dir, which is located in my WAMP dir. In my "www" dir I have a folder named "CI" where all the CI files are located. My base_url is: http://localhost/CI/

Do you understand? Wink

i understand what your saying but i think my ultimate problem is that my local server is not recognizing the function it seems. In theory it shouldn't matter what i write in the file. in my case "c:/web" if the function was recognized it should still print "c:/web" where ever the function is called? Is my thinking right or wrong? Because right now when ever i have this function un-commented out it kills the script on the page.

i uploaded this to my server...

here's the error
Fatal error: Call to undefined function base_url()

Yes, it should print whatever you're writing in the variable. Did you auto load the "URL" helper? It's kinda weird, because I thought base_url() would work when you've just installed CI on your server. Anyways try to auto load the helper if you haven't done that yet and see what happens.


Yeah that worked. Is there anything else i should need without getting too involved?

Well, what I do is auto loading my database, form helper, url helper, html helper, nothing further unless I of course need something else, but that's just standard. So I guess you're up-to-date now Smile

Theme © iAndrew 2016 - Forum software by © MyBB