Welcome Guest, Not a member yet? Register   Sign In
MySQL Data Retrieval
#1

[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


Messages In This Thread
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:12 AM
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:58 AM
MySQL Data Retrieval - by El Forum - 06-17-2009, 05:19 PM
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:51 PM
MySQL Data Retrieval - by El Forum - 06-18-2009, 02:16 AM
MySQL Data Retrieval - by El Forum - 07-01-2009, 01:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB