Welcome Guest, Not a member yet? Register   Sign In
CI with MySQL client library 4.1.11 bug, mysql_set_charset does not exist resulting in blank pages
#1

[eluser]Michael Brooks[/eluser]
I think there is a bug in the mysql_driver.php file.

On my server, I was finding that when I loaded the database I got nothing but blank pages. Eventually, I pinpointed the problem to line 150 in mysql_driver.php, within the db_set_charset() method:

Code:
return @mysql_set_charset($charset, $this->conn_id);

The error suppression was hiding the fact that mysql_set_charset() is not defined.

According to documentation in the db_set_charset() method, the mysql_set_charset() function is used when PHP >= 5.2.3 and MySQL >= 5.0.7. When these conditions aren't met it falls back to SET NAMES.

My server is using MySQL server version 5.0.45 and PHP 5.2.4, so it passes this test. However, it is using version 4.1.11 of the MySQL client library, which doesn't support mysql_set_charset(). I found this information here: http://www.php.net/manual/en/function.my....php#80997
#2

[eluser]Michael Brooks[/eluser]
Here is my fixed version of the mysql driver's db_set_charset method, which seems to work for me:

Code:
function db_set_charset($charset, $collation)
{
    if ( ! isset($this->use_set_names))
    {
        // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7 and MySQL client >= 4.1.13, use SET NAMES as fallback
        $this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') &&
            version_compare(mysql_get_server_info(), '5.0.7', '>=') &&
            version_compare(mysql_get_client_info(), '4.1.13', '>=')) ? FALSE : TRUE;
    }

    if ($this->use_set_names === TRUE)
    {
        return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
    }
    else
    {
        return @mysql_set_charset($charset, $this->conn_id);
    }
}
#3

[eluser]Michael Brooks[/eluser]
Would anyone confirm or deny that this is a legitimate problem with CodeIgniter 2.1.0?
#4

[eluser]jmadsen[/eluser]
Hey Michael,

Although this is the right place, you'll probably get a better look & response from opening a github issue:

https://github.com/EllisLab/CodeIgniter/issues




Theme © iAndrew 2016 - Forum software by © MyBB