PHP Error with First Yii Application


when creating the first yii application according to the documentation I get following error when calling site via browser:

PHP Error


mb_strrpos() [<a href='function.mb-strrpos'>function.mb-strrpos</a>]: Empty haystack

Source File


00119:         else

00120:             list($controllerID,$actionID)=$this->resolveRequest();

00121:         $this->runController($controllerID,$actionID);

00122:     }


00124:     /**

00125:      * Resolves the current request into controller and action.

00126:      * @return array controller ID and action ID.

00127:      */

00128:     protected function resolveRequest()

00129:     {

00130:         $route=$this->getUrlManager()->parseUrl($this->getRequest());

00131: if(($pos=strrpos($route,'/'))!==false)

00132:             return array(substr($route,0,$pos),(string)substr($route,$pos+1));

00133:         else

00134:             return array($route,'');

00135:     }


00137:     /**

00138:      * Creates the controller and performs the specified action.

00139:      * @param string controller ID

00140:      * @param string action ID

00141:      * @throws CHttpException if the controller could not be created.

00142:      */

00143:     public function runController($controllerID,$actionID)

Stack Trace

#0 /var/www/html/yii-1.0.1.r473/framework/web/CWebApplication.php(131): mb_strrpos()

#1 /var/www/html/yii-1.0.1.r473/framework/web/CWebApplication.php(120): CWebApplication->resolveRequest()

#2 /var/www/html/yii-1.0.1.r473/framework/base/CApplication.php(162): CWebApplication->processRequest()

#3 /var/www/html/fm/index.php(11): CWebApplication->run()

This error occures on CentOS 5.2 with php 5.1.6 installed and with yii-1.0.0 and yii-1.0.1.

I've tried to log $this->getRequest() to error log - The only entry is: 1

Please tell me which further steps should be performed to investigate the error.

Best Regards


hmm…it seems you set mbstring.func_overload to be true in your php.ini, which causes strrpos to be overloaded by mb_strrpos. The latter would report a warning if the first parameter is empty.

Try to change your php.ini setting for now. I will go through the framework code to avoid this problem.

you were right -

As we need this option for other projects i've created an .htaccess file with following content.

php_value mbstring.func_overload '0'

now it works as expected.

Thank you for the information.

Best Regards

hm… ok - only one step further -

I copied a project from one server to another. Database has been copied also - a mysql-user has been created. acces to the appropriate database is granted. Settings in  <projectdir>/protected/config/main.php has been updated.

                'db' => array(


                        'username'      => 'fm',

                        'password'      => 'fm',

                        'charset'       => 'UTF8'

after login I get following error:



CDbConnection failed to open the DB connection: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1

Source File


when checking the query log of mysql i can see, that a connection is established, but no queries are executed against the database.

Best Regards

It seems to be caused by the charset property. When you set this property, the following SQL will be executed after the connection is established:

$stmt=$pdo->prepare('SET CHARACTER SET ?');


hm… seems to be a problem with the pdo-module of RHEL 5.2 / CentOS 5.2. with php 5.1.6. When i install the project on Fedora 9 with PHP 5.2.6 all works as expected.

after disabling the charset attribute i got following error:

[tt]CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet[/tt]

I found the solution in this post:


I set the emulatePrepare value to true and now the project works also on PHP 5.1.6

Best Regards


Good you found the solution. I was about to say the emulatePrepare thing.