简体   繁体   中英

500 internal server error in yii framework

在此处输入图片说明 I have a problem with Yii framework, everything was working locally jz fine but when I tried to move my app to another system some of the views are showing errors like 'undefined variables'. anyone know about this issue.

I found some similar issues with yii but none of them provided a correct answer for me.

EDIT

actually I have 2 dropdown boxes, 1st one is getting the value from the model, if we select 1 from 1st dropdown list it will filter the results and shows in the second dropdown list(ajax call), both dropdown boxes using different controller action

And in firezilla I am getting the 500 internal server error for the request and following image contains log as response.

The errors concerning undefined variables where probably always there, but not shown due to less strict values of the error_reporting and display_errors configuration directives.

Undefined variables do not usually cause a 500 internal server error. Consult the log file of the web server for details on those errors.

It can happen if you are using PHP 5.2 on you local dev machine and other systems use 5.3. In 5.3 if there's some undefined variable ($result in your case) PHP will throw you a notice by default .

Few years ago, when I moved Yii project from 5.2 to 5.3 I got lots of these.

I had exactly the same problem. My website with ajax works perfectly in the localhost. but when i uploaded it to the server, I realized the ajax request where not workin returning the 500 internal error. And when i click the url it says that undefined variable. Solution: Check the url of the ajax request: before:

echo CHtml::textField('idsearch', '', array(
    'onKeyUp' => CHtml::ajax(
            array(
                'type' => 'POST',
                'dataType' => 'html',
                'data' => array(
                    'id' => 'js:idsearch.value'),
                'update' => '#dvfeeform',
                'url' => CController::createUrl('student/searchajax'),
    ))
));

after editing the url to:

'url' => Yii::app()->createUrl('student/searchajax'),

it worked perfectly fine. hope it may help someone someday

I have passed an empty array $result from the controller to the view, Now its working fine.

But till now I couldn't figure it out why it worked perfectly in my local host and not in the other system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM