Welcome Guest, Not a member yet? Register   Sign In
Problem with including Full Path CodeIgniter.php
#1

[eluser]life_time_learner[/eluser]
Hi, I have just begun learning CodeIgniter. And everything runs fine for me in localhost environment. Then when I moved the code to the server environment, and the view pages could not be displayed anymore. It happed to few hosts such as Godaddy, BlueGenesis and so on. I have noticed for some strange reasons I could not include the absolute path

if ( ! include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
{
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}
, any codes beyond this part could not be executed unless the file contains only simple HTML code like

<p>Hi</p>

instead of

&lt;?php
class Blog extends Controller()
{
function Blog()
{
parent::Controller();
}
function index()
{
//$this->load->view('show.html');
echo "I could not run this ";
}
}

?&gt;

I have used is_dir() and file_exists to check the file path, it froze (displayed blank
page)

ext

$file_path = APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT;

if(file_exists($file_path))
echo "This file exists"
else
echo "This file does not exist";

Anyone knows why?

Thank you for your kindly response in advance.
#2

[eluser]James Gifford[/eluser]
I'm not quite sure I understand the exact problem you're having, but after you uploaded to your live server did you update the config.php file to reflect the new url?

Also, is there any difference between your test environment and your live server such as directory names, PHP versions, or operating systems?
#3

[eluser]life_time_learner[/eluser]
Thank you for your reply. I did specified the $config['base_url] to my server URL. And I am pretty sure it is the server side problem like the setting of php. Right now I am debugging the CI framework at Godaddy server.

And I found that

$RTR =load_class('Router');

is not working properly

and I always getting

404 Page Not Found
The page you requested was not found

I am trying to solve this problem now.
#4

[eluser]Michael Wales[/eluser]
Are you sure you have the router library uploaded?

Definitely odd because the Router class is not the first class loaded. Load order up to that point is:
Benchmark
Hooks
Config
URI
Router

If it was an issue with paths, benchmark would have failed. Turn on logging and let's see what CI's log files show...
#5

[eluser]life_time_learner[/eluser]
I am 100% sure .


Fatal error: require() [function.require]: Failed opening required '/home/content/s/i/b/sibtadmin/html/system/libraries/Router<br/>.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/s/i/b/sibtadmin/html/system/codeigniter/Common.php on line 113


after my own trace this morning. Have to go to work now



In BASEPATH library path checkAfter Assigning CI_Benchmark before reutrn in load_class

Benchmark

In BASEPATH library path check
In BASEPATH library path checkAfter Assigning CI_Config before reutrn in load_class

After Assigning CI_Hooks before reutrn in load_class

Hooks
pre_system
Config

In BASEPATH library path checkAfter Assigning CI_URI before reutrn in load_class

URI

In BASEPATH library path checkAfter Assigning CI_Exceptions before reutrn in load_class

A PHP Error was encountered

Severity: Warning

Message: require(/home/content/s/i/b/sibtadmin/html/system/libraries/Router<br/>.php) [function.require]: failed to open stream: No such file or directory

Filename: codeigniter/Common.php

Line Number: 113


Need to squeeze sometimes to work on it. Thank you for your reply again.
#6

[eluser]life_time_learner[/eluser]
Please ignore the previous post since there is a mistake I made in the load_class() function which I passed a <br/> tag there. Here is the most recent update

Benchmark
Hooks
pre_system
Config
URI


404 Page Not Found

The page you requested was not found.
#7

[eluser]life_time_learner[/eluser]
Just stating my progress now. I have looked into the deep root of Router.php located in config folder, and found that

is_dir(APPPATH.'controllers/'.$segments[0]

part failed and show_404() function is triggered. I have specified the $route['default_controller'] = "Share";

For some reason , the server doesn't like the captical, therefore I change it to small share in the routes.php under config, and same to the file name in the controllers folder. Now instead of getting page not found error, I am getting


An Error Was Encountered

Unable to load the requested file: Media_Share/index.php


Just to clarify things, I have no problem running CI in localhost environment. And I have noticed that there are some server problems in Godaddy and they do not provide scripting help including .htaccess modification. Before I did encountered the same problem which I have ignored since I was playing with other frameworks and got no time. Now I decided to go through all the pain to find out the true reason for what is the cause of Godaddy to refuse CI.

Thank you for all of your kindly response.
#8

[eluser]life_time_learner[/eluser]
Hi, all. Thank you for your attention. I have solved the problem. What I did is I have removed some & from Router.php, Common.php, CodeIgniter.php since I am working in a php5 environment.



example

$LANG = &load;_class('Language');

will be changed to

$LANG = load_class('Language');


And also specify exact same file path and default index file name

example

$this->load->view('media_share/index.php',$data);

you must have a media_share folder under views and index.php under the media_share folder, it is case sensitive in Linux/Unix environment, which means Media_share folder name won't work in this case. But in Window environment , it is ok.

Thank for all your reply. This ends the topic.




Theme © iAndrew 2016 - Forum software by © MyBB