CodeIgniter Forums
Default controller not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Default controller not working (/showthread.php?tid=50210)



Default controller not working - El Forum - 03-18-2012

[eluser]wallern[/eluser]
Hi, I just pulled out an old version of CI (1.7.2) website from ftp, doing some upgrade work. However, after configuration in config, routes, database, .htaccess, I cannot get my default controller running. It looks like the default controller is called but cannot be executed. When I echo out something above the default controller, it appears. Other than that I get a blank white page.

As I'm not quite familiar with older version of CI, appreciate if anyone could give me some advise, maybe I missed something. Thanks in advance!


Default controller not working - El Forum - 03-18-2012

[eluser]InsiteFX[/eluser]
Check for white space in your html file, make sure your pages are not be saved with BOM.




Default controller not working - El Forum - 03-18-2012

[eluser]wallern[/eluser]
[quote author="InsiteFX" date="1332135963"]Check for white space in your html file, make sure your pages are not be saved with BOM.

[/quote]
Thanks so much for your reply. However, I don't understand what do you mean by "not be saved with BOM".
I checked the page source, it's the same blank, nothing there.


Default controller not working - El Forum - 03-18-2012

[eluser]wallern[/eluser]
Here is my configuration:
my code is in the htdoc root folder, I use xampp. I have a few other websites in subfolders they worked fine, and I just moved them out leave only this website.

config.php

Code:
$config['base_url'] = "http://127.0.0.1/";
$config['base_path'] = FCPATH;
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";


.htaccess

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteBase /
    RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|js|css|pdf|txt) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1
</IfModule>

I use this code to test my DB connection,

Code:
echo '<pre>';
print_r($db['default']);
echo '</pre>';

echo 'Trying to connect to database: ' .$db['default']['database'];
$dbh=mysql_connect
(
  $db['default']['hostname'],
  $db['default']['username'],
  $db['default']['password'])
  or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db['default']['database']);

echo '<br />   Connected OK:'  ;
die( 'file: ' .__FILE__ . '--&gt; Line: ' .__LINE__);

and it shows:

Code:
Array
(
    [hostname] => localhost
    [username] => root
    [password] => pass
    [database] => dbname
    [dbdriver] => mysql
    [dbprefix] =>
    [pconnect] => 1
    [db_debug] =>
    [cache_on] =>
    [cachedir] =>
    [char_set] => utf8
    [dbcollat] => utf8_general_ci
)

Trying to connect to database: dbname
Connected OK:file: C:\xampp\htdocs\system_newsite\application\config\database.php--&gt; Line: 80

So I think the database connection is ok. If need any other info please let me know, I'm really run out of juice on this one. Once again, thanks for help!


Default controller not working - El Forum - 03-19-2012

[eluser]aquary[/eluser]
Can you check in your error logs? most of the time, if the page got blank, errors should already be logged be the server.


Default controller not working - El Forum - 03-19-2012

[eluser]wallern[/eluser]
Thanks aquary,

I checked error logs in both apache and CI, no error shows when I get the blank page. But the error logs are working, I mean if I deliberately put some wrong code in index.php or config.php or database.php, errors will get booked in the logs. To me it looks like the default controller is not loading.

I also have a back end CMS of this site running ok locally, and site itself is working fine on production server, just dosen't show up in my localhost.


Default controller not working - El Forum - 03-19-2012

[eluser]CroNiX[/eluser]
ini_set('display_errors', 1);
error_reporting(E_ALL);


Default controller not working - El Forum - 03-19-2012

[eluser]wallern[/eluser]
[quote author="CroNiX" date="1332198090"]ini_set('display_errors', 1);
error_reporting(E_ALL);[/quote]
Thx, I put this code in config.php and then I refresh the page and check error logs, still can't see any updates.


Default controller not working - El Forum - 03-19-2012

[eluser]InsiteFX[/eluser]
Try changing:
Code:
// this
$config['uri_protocol'] = "AUTO";

// to
$config['uri_protocol'] = "REQUEST_URI";

Also change this .htaccess:
Code:
// from this
<IfModule mod_rewrite.c>

// to this
<IfModule mod_rewrite.so>



Default controller not working - El Forum - 03-22-2012

[eluser]wallern[/eluser]
Hi, sorry for my interruption on this topic. The good news is I got it works. After I change the uri protocol to:

Code:
$config['uri_protocol']="REQUEST_URI";

I finally be able to see one error message:

Code:
Call to undefined function: curl_init()

This two links really helped me:
http://www.hotscripts.com/forums/php/26167-fatal-error-call-undefined-function-curl_init.html
http://php.net/manual/en/function.curl-init.php

Basically, I enabled curl support in my php.ini file by uncomment this line:
Code:
extension=php_curl.dll
Then everything shows up... Hope this helps people who have scenarios like me - work on an old piece of CI never touched before and having hard time on getting site from production server to local or vice versa.

Cheers all!