Welcome Guest, Not a member yet? Register   Sign In
Problem with /system/database/DB.php
#1

[eluser]davidfkane[/eluser]
Hi All,

This is my first post, so sorry it's a bug report. C.I. is really great, but I am having a problem. I have done my best to isolate the cause.


::The Problem::
I am developing a simple CRUD application on CI. The application worked fine on windows 7, but not on my current Linux setup. Pages that load models (encapsulating DB entities), give blank pages or a 500 server error. Try as I might, I can't get any kind of informative error message, either through PHP or in any log files.

::The Set-up::
I was running Ubuntu 10.4 (and having the same problem after upgrade to 11.4)
PHP 5.3.3
MySQL 5.1.49
Apache 2.2.
- generous permissions in the CI directory tree (chmod -R 777 *)

::What I Have Figured Out So Far::
Right at the bottom of the /system/database/DB.php file is the line of code that seems to be causing all the problems.

it is:

Code:
if ($DB->autoinit == TRUE)
    {        
        // print() something here and it can be seen
        $DB->initialize();
        // but print() something here and it is not seen (!)
    }

In fact, the particular line that causes the trouble is
Code:
$DB->initialize();

My DB settings are in order. They are:

Code:
$active_group = 'default';
$active_record = FALSE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "dkanepass";
$db['default']['database'] = "mylibrarydb";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

I am finding it so hard to trace the error beyond this initialize() function. Any help would be greatly appreciated.

Thanks,

David
#2

[eluser]WanWizard[/eluser]
CI code doesn't generate a 500 error, your webserver does. Often it's because of database connection issues that causes your script to hang on a connection timeout.

Make sure error reporting is set to E_ALL and display errors are enabledis set to On in your php.ini, you might get an error message. Also, check your apache logs for possible errors.
#3

[eluser]davidfkane[/eluser]
Hi WanWizard. Thanks for the quick reply.

Well, I am not sure if it is even generating an 500 error. My 'firebug' seems to think so. But, I am not sure. I just get absolutely nothing, unless I print() stuff in the DB.php file, as I indicated in my first post.

I have switched on error reporting in php.ini and have also tailed the apache and mysql logs but have found nothing. It is very frustrating to debug with no obvious source of error. I am not sure what it is. I just hope it is something trivial.

Altering the database connection fields in the DB settings (above) does not coax any errors out either - still blank pages.

David.
#4

[eluser]davidfkane[/eluser]
Well. This is embarrassing.

I figured the problem was with the database connection so I tried some simple db connection code to see if I could coax out some nice errors from PHP. It worked..

I got:

Code:
Fatal error: Call to undefined function mysql_connect() in ...

and so, it was solved by:
Code:
apt-get install php5-mysql

I do think it is a disadvantage that CI doesn't allow these errors to bubble up to the surface. Neither does it log them, not by default anyway. So perhaps that's a kind of bug, or at least something that could be looked at.

Best,




Theme © iAndrew 2016 - Forum software by © MyBB