Characters appear as gibberish in mysql

Strange thing. The site is in Russian language utf-8 , works great. Site, admin panel is showing in Russian perfectly. When I create forum or topic, everything works right. But I decided to check DB, and Russian shows as gibberish. If I edit a table with Russian word through MySQL directly, it shows as Russian in MySQL, but in the website is shown as question marks “?”. What can it be? I try’d changing tables to utf8mb4 , nothing working.

I can’t figure out where to place set_charset(“utf8”).

    function &get($aConf = array())
        {
            static $aInstances = array();

            if (! $aConf)
                $aConf = App::getParam('db');

            $sKey = serialize($aConf);
            if (! isset($aInstances[$sKey]))
            {
                $aInstances[$sKey] = & new Database();
                $aInstances[$sKey]->connect($aConf['host'], $aConf['name'], $aConf['user'], $aConf['pass']);
            }
            return $aInstances[$sKey];
        }


        /** Connects to database server and selects db.
         * @param string $sHost database host
         * @param string $sName database name
         * @param string $sUser user name
         * @param string $sPass user password
         * @return boolean
         * @access public
         */
        function connect($sHost, $sName, $sUser, $sPass)
        {
            $this->_hLink = mysql_connect($sHost, $sUser, $sPass);
            if (! $this->_hLink)
            {
                $this->_addError('db.connect', array($sHost, $sUser,''), true);
            }
            if (! mysql_select_db($sName, $this->_hLink))
            {
                $this->_addError('db.select_db', array($sHost, $sName, $sUser,''), true);
            }
            return true;
        }

        function databaseError($sSql,$sStr)
        {
            trigger_error("<b>Mysql Query:</b>". $sSql ."<br /><b>Mysql Error:</b> ". $sStr ."");
            exit;
        }

Your code and Php version are severely out of date. I would start there first.

Why? it works. Fast too.

Sponsor our Newsletter | Privacy Policy | Terms of Service