Nikhil Dinesh
Nikhil Dinesh

Reputation: 3409

500 internal server error in yii framework

enter image description hereI 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.

Upvotes: 0

Views: 21791

Answers (4)

masoud
masoud

Reputation: 11

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

Upvotes: 1

Sergiy G
Sergiy G

Reputation: 11

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.

Upvotes: 1

Nikhil Dinesh
Nikhil Dinesh

Reputation: 3409

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.

Upvotes: 0

Oswald
Oswald

Reputation: 31637

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.

Upvotes: 2

Related Questions