Failed to search Server-side Data (utf8)

Failed to search Server-side Data (utf8)

stepfstepf Posts: 4Questions: 0Answers: 0
edited September 2009 in General
I have no problem if i hard-coded the chinese characters in DOM for searching

My Testing 1:
http://idio.co.nz/test/dataTables-1.5/examples/data_sources/dom.html
Search: ?? (data in column: Rendering engine)

However, the search is just not working when i pump the utf8-bin/ utf8-general-ci data from MySql.
Is there a way for me to echo my $sQuery from the php for debug?

My Testing 2:
Search: ?? (data in column: Platform(s)) -> return 0 rows
http://idio.co.nz/test/dataTables-1.5/examples/data_sources/server_side.html

Thanks for all your help!

Replies

  • stepfstepf Posts: 4Questions: 0Answers: 0
    edited September 2009
    hmm.. "??" is actually the utf8 inputs

    For Testing 1: you may search "Stephanie" & copy the chinese char to test on "search"

    For Testing 2: you may copy data (utf8-general-ci) from the 2nd rows, column: platform(s) to test on the "search"

    Thanks.
    Regards,
    Stephanie
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Stephanie,

    It might be worth having a look at this thread, which details how ChrisS got UTF8 to work as expected: http://datatables.net/forums/comments.php?DiscussionID=411

    Also for debugging the MySQL queries, a good way of going this is using the error-log() function in PHP ( http://uk.php.net/manual/en/function.error-log.php ) and viewing the error log for your host (assuming you are using Apache).

    Regards,
    Allan
  • stepfstepf Posts: 4Questions: 0Answers: 0
    edited September 2009
    Hi Allan

    Thanks for the reply.

    My hosting is IIS6 and it's quite difficult to request for a change in server setting.

    Here's my solution, hope this helps.

    You can put the following codes after MySql connections

    [code]
    //To send utf8 data to MySql - needed if you need to inject utf8 data for search
    mysql_query("SET character_set_client=utf8", $gaSql['link']);
    mysql_query("SET character_set_connection=utf8", $gaSql['link']);

    //To read utf8 data from MySql - needed if your result set contains utf8 data
    mysql_query("SET character_set_results=utf8", $gaSql['link']);

    $rResult = mysql_query( $sQuery ) or die(mysql_error());
    [/code]

    Since i have no access to the host, therefore, i ouput a file to read my query :)

    [code]
    $myFile = "test.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $sQuery . "\n\n");
    fclose($fh);
    [/code]

    Again, goooood job allan, DataTables is really a fantastic work.

    Regards
    Stephanie
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Stephanie,

    Fantastic! Thanks for sharing that with us :-). I can tell this is one of the threads I'll be copying and pasting the url of in future :-)

    Regards,
    Allan
This discussion has been closed.