In my earlier post php-mysql connection charset fix, I mentioned I was having issues with enforcing an UTF8 charset. I found the solution:
@$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
// or die(mysql_error());
if (!$conn||mysqli_connect_errno())
{
throw new Exception(’Could not connect to database server:’.
mysqli_connect_error());
}
else
{
$conn->query( “SET NAMES ‘utf8′” );
$conn->set_charset(”utf8″);
return $conn;
}
Category Archives: mysql
php-mysql connection charset fix
January 16, 2008 – 2:16 pm