Online Promoters™ :: Web Development made simple

Blank screen in Code Igniter – CI – after upgrade – 5.2.6 PHP server [SOLVED]


If you are a Code Igniter developer and you are using PHP 5.2.6 you might be interested in this post. Getting a blank screen can mean a LOT of things. In an particular scenario while running PHP 5.2.6 (on a Windows machine) when installing/upgrading to Code Igniter 2.0.3 you get a blank screen. This happens because the current version of PHP does not support a function and the error is suppressed by @ sign. Supposedly this function was added after PHP 5.2.3 was released, but this error was found on a server running PHP 5.2.6.

[SOLUTION]
In your "system" folder from your CI core files edit this file /database/drivers/msyql/mysql_driver.php, in line 125, by replacing the function "db_set_charset" with the following one.

[sourcecode language="php"]
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
static $use_set_names;

if ( ! isset($use_set_names))
{
// mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
$use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
}

if ($use_set_names)
{
// not supported on some servers (i.e. mediatemple)!
if(function_exists('mysql_set_charset'))
return mysql_set_charset($charset, $this->conn_id);
else
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
}
}
[/sourcecode]

This should get you going!

Source: Code Igniter forum