Yii Framework Forum: PHP Error with First Yii Application - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHP Error with First Yii Application Rate Topic: -----

#1 User is offline   Senator 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-January 09

Posted 14 January 2009 - 03:46 PM

Hello,

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

PHP Error
Description

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

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

00119:        else
00120:            list($controllerID,$actionID)=$this->resolveRequest();
00121:        $this->runController($controllerID,$actionID);
00122:    }
00123:
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:    }
00136:
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
Senator
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 14 January 2009 - 04:03 PM

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.
0

#3 User is offline   Senator 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-January 09

Posted 14 January 2009 - 04:22 PM

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
0

#4 User is offline   Senator 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-January 09

Posted 14 January 2009 - 04:53 PM

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(
                        'connectionString'=>'mysql:dbname=fm',
                        'username'      => 'fm',
                        'password'      => 'fm',
                        'charset'      => 'UTF8'


after login I get following error:
CDbException
Description

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

/var/www/html/yii-1.0.1.r473/framework/db/CDbConnection.php(233)

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

0

#5 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 14 January 2009 - 09:22 PM

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 ?');
$stmt->execute(array($this->charset));

0

#6 User is offline   Senator 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 14-January 09

Posted 15 January 2009 - 06:31 AM

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:
http://www.yiiframew...php?topic=407.0

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

Best Regards
Senator

0

#7 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 15 January 2009 - 06:38 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users