I have been trying so long but couldn't find a solution. For some reason I need to access the codeigniter super object get_instance() from an external php script which is located outside codeigniter installation.
So for example, I have a custom php script called my_script.php inside public_html. And the codeigniter is installed inside public_html/codeigniter.
Followed by the discussion here: http://ellislab.com/forums/viewthread/101620/ I created a file called external.php and put it inside public_html/codeigniter folder, it contains the following code:
<?php
// Remove the query string
$_SERVER['QUERY_STRING'] = '';
// Include the codeigniter framework
ob_start();
require('./new/index.php');
ob_end_clean();
?>
Then I created a file called my_script.php and put it inside public_html folder (outside codeigniter installation), it contains the following code:
<?php
require('new/external.php');
$ci =& get_instance();
echo $ci->somemodel->somemethod();
?>
Now when I load the my_script.php file from browser, it produces following error:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
If I put the my_script.php file inside codeigniter folder with corrected file path in require() function then it works. But I really need it to work from outside codeigniter installation.
Any idea how to get rid of this problem?
Thanks in advance.