Welcome Guest, Not a member yet? Register   Sign In
I am having problems using base_url, setting maybe?
#1

[eluser]The Beginner[/eluser]
Hi all, it's me again. I finished playing with tutorials and dynamic menus and nested views. I created a new instance of CI and started my project and the first time I needed to get the base url it failed with an error A PHP Error was encountered, Severity: Notice, Message: Undefined variable: base_url, Filename: controllers/wpapp.php, Line Number: 15.
I have tried every variation of the call that I can think of and still the error. I have set $config['base_url'] = "http://localhost/CI/";in config.php, I have also in my controller included $this->load->helper['url'];
I have looked through all the files in my tutorials copy and I am using base_url there in several places and it works fine.
Any suggestions?
Thanks,
Del
:-S
#2

[eluser]BrianDHall[/eluser]
Check your config.php file, the base_url is set there. Double-check you aren't both auto-loading it and loading it manually, as well.
#3

[eluser]The Beginner[/eluser]
Thanks, That is what I mentioned in my last post, I set it in config.php and I have checked it over and over again. I am really confused as to why it is not working. I can switch back to my original project and it still works fine. In fact I just copied all my config files from the tutorials project to my new one and it made no differance.
I am starting to think I have some setting in my server that may be afecting it, but if that were the case it probably would not work in the old setup.
Thanks again for your responce.
#4

[eluser]BrianDHall[/eluser]
Oops, my bad I missed the part where you checked the config, sorry about that.

If you haven't gotten any work done in the new install I recommend you just get a new zip of CI 1.7.2 and make sure the welcome controller it comes with works ok, then go from there.

It'll probably just 'work' with no explanation as to what went wrong, but that's how it goes sometimes.

The other option is to setup a debugger with an IDE, such as Netbeans with XDebug, set a breakpoint before the error, then step into the call to base_url to see what's up.
#5

[eluser]The Beginner[/eluser]
Thanks,
What is really wierd, after I posted the lat post I set $data['burl'] = "http://localhost/CI/" and that got me going. At that point the base_url() started working. #$%^&*()_ go figure. I set up my header and menu they both worked fine. Then I started coding my main page, and now CI does not seam to be passing $data from one view to the next. I tested it worked then I added the string helper and passed in a couple of new strings into my header view and boom, it broke. I reverserd what I did and it is still broke. Maybe I have been working on this to hard and need to take a couple of days off. lol
I think when I start back I will get a debugger. I have Delphi for PHP but have not tried it in the CI framework.
Anyway, thanks a lot for your help. I really appreciate it.
Del
#6

[eluser]BrianDHall[/eluser]
If its being really weird all over, I would take a break like you said and if still not, I'd do a fresh install and selectively copy/paste over the stuff you need from your new project. Its easy to change something small when you are starting and forget all about it, or sometimes just accidentally change something with a stray keystroke and corrupt a file and not find out till much later.

Not to be a big drum-banger for IDEs, but having access to a debugger has been the biggest single improvement I've had in programming since picking up CI itself. My debugger stopped working a few days ago after screwing around with my localhost server and I felt lost without it, I'd have installed ubuntu in dual boot if I had to just to get it working Smile

Best of luck!
#7

[eluser]InsiteFX[/eluser]
You also need to set your system and application folders in index.php

Enjoy
InsiteFX
#8

[eluser]The Beginner[/eluser]
In Index.php my system folder is: $system_folder = "system"; and my application path is: $application_folder = "application";
My base url is: $config['base_url'] = "http://127.0.0.1/xampp/CI/";
I moved application from system/application to the base url as suggested in a tutorial. now my structure is: /CI/ -> application
system
user_guide
index.php
license.txt

I noticed in index.php there is this: require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
the codeigniter folder is located in system/codeigniter, so should I change that?
Thanks,
Del :question:
#9

[eluser]InsiteFX[/eluser]
Try this in index.php

system folder = ../system

application folder = ../application

Enjoy
InsiteFX
#10

[eluser]The Beginner[/eluser]
Tried that...:
Warning: require_once(../system/codeigniter/CodeIgniter.php) [function.require-once]: failed to open stream: No such file or directory in C:\xamp\htdocs\xampp\wpapp\index.php on line 115

Fatal error: require_once() [function.require]: Failed opening required '../system/codeigniter/CodeIgniter.php' (include_path='.;\xamp\php\PEAR') in C:\xamp\htdocs\xampp\wpapp\index.php on line 115

I am at a total loss, I just created yet another brand new instance and started from scrach and as soon as I start passing $data from one view to the other I get an error.

Below is my code in a file called Container.php...:

<html>
<head>
<title><?php echo $title; ?></title>
<?php
$data['burl'] = "http://127.0.0.1/xampp/wpapp/";
$this->load->view('wpMeta',$data);
?>
</head>
<body>
<?php
$this->load->view('wpHeader', $data);
$this->load->view('wpMenu', $data);

NOTE: When I load the wpMenu view it does not see $data and fails.

// $this->load->view('sidebar', $data);
// $this->load->view($page, $data);
// $this->load->view('footer');
?>
</body>
</html>

The call to load container is done from my controller like...:

$this->db->where('wp_header_active', '1');
$querydata = $this->db->get('wp_header_data');
if ($querydata->num_rows() > 0):
foreach($querydata->result() as $row):
$data['header_logo'] = snappy_image($row->wp_header_logo, 'My Picture', 'somestyle');
$data['title'] = $row->wp_header_name;
endforeach;
endif;
$querydata->free_result();
$data['burl'] = "http://127.0.0.1/xampp/wpapp/";
$this->load->view('wpContainer',$data);




Theme © iAndrew 2016 - Forum software by © MyBB