[eluser]bhogg[/eluser]
Hi all,
A quick question. I have the following code to retrieve a post:
Code:
// Connect to the database then get the data
$connection = @mysql_connect($hostname, $username, $password) or $error = TRUE;
@mysql_select_db($database) or $error = TRUE;
$query = mysql_query("select content from posts where id = 3571");
if ($row = mysql_fetch_assoc($query))
echo($row['content']);
// Use a class to do it
$post = Post::Get(3571);
echo $post->content;
The first bit uses mysql functions directly, the second uses CodeIgniter database class to retrieve the data in a similar way. There's no wrapping in an escape function or anything, and the charset for CI is set to UTF-8.
Problem is the MySQL is retrieving the data nicely (it was inserted using mysql standard code, whereas the CodeIgniter version is retrieving symbols in place of certain characters. The database collation is utf8_generai_ci.
Any ideas why they would ever differ?
Cheers,
Brian