0
public function actionSearch()
{   
     $this->showsearch = 1;
     $data['keyword'] = isset($_REQUEST['keyword']) $_REQUEST['keyword']:NULL;
     $data['option'] = isset($_REQUEST['option'])?$_REQUEST['option']:array();
     $data['country'] = isset($_REQUEST['country'])?$_REQUEST['country']:NULL;
     $this->render('search', $data);

}

In my View I have,

<?php echo CHtml::textField('keyword', $keyword, array('style' => 'width:97%;')); ?>

The output says,

500
Undefined variable: keyword.

Can you tell me what the error is?

3 Answers 3

1

There is a missing '?' after isset($_REQUEST['keyword']). It should be :

$data['keyword'] = isset($_REQUEST['keyword'])? $_REQUEST['keyword']:NULL;
Sign up to request clarification or add additional context in comments.

Comments

1

You need to check if there is some request first

if (isset($_REQUEST['keyword']))

When you just first load the page there is no request.

Comments

0

Do you have property keyword in your model?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.