Please login or register.

Login with username, password and session length
Advanced search  


You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Charset Database  (Read 1220 times)


  • Full Member
  • ***
  • Karma: 6
  • Posts: 194
Charset Database
« on: January 10, 2012, 07:15:11 pm »

Hello everybody,
Happy new-year.

Recently I was working with someone on a specific project in sNews 1.7. There was some problem in MySQL database with charset. To resolve this problem we just add this sentence in Connect to database function.
Code: [Select]
function connect_to_db() {
   $db = mysql_connect(db('dbhost'), db('dbuname'), db('dbpass'));
   // Set charset
   mysql_query("SET NAMES 'utf8'");
   mysql_select_db(db('dbname')) or die(l('dberror'));
... etc

Then there is no more problem with accents in a French database.
Maybe this can resolve different problem for user working in other langage than English ?

You can try.



  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
Re: Charset Database
« Reply #1 on: January 10, 2012, 10:37:33 pm »

Hi Steph, Happy New Year to you too!  :)
Thanks for sharing this work-around. I hope it is useful for others using languages other than English.
I always make sure I use utf8 when I create the new database before I populate it with the tables.
Do it now... later may not come.
sNews 1.6 MESU | sNews 1.6 MEMU


  • Newbie
  • *
  • Karma: 1
  • Posts: 18
Re: Charset Database
« Reply #2 on: April 18, 2012, 10:03:38 pm »

Wow... this saves my day after struggling for 5 hours. In my case, I got the front end working alright, but mysql was converted my Thai into weird characters. I applied your code and it worked like charm. I had to re enter all my content though.

Many thanks. ;)