3

I have the following view-code for search key input from user:

       <?php echo CHtml::beginForm(Yii::app()->createUrl('home/search'),'get',array('accept-charset'=>'UTF-8', 
            'enctype'=>'multipart/form-data'));?>
                        <div class="search-box">
                            <div class="input-box left">
                                <input type="text" name="q" id="t-search" class="txt-box"
                                       placeHolder="<?php echo Yii::t('website', 'enter.search.keyword.here'); ?>"/>
                            </div>
                            <div class="left">
                                <input type="submit" id="b-search" class="btn main-bg" value="GO"/>
                            </div>
                        </div>
                        <?php echo CHtml::endForm();?>

In the controller i have following search action:

public function actionSearch($q)
{
    Yii::app()->theme = "website";
    $this->layout = '//layouts/main';
    $this->pageTitle = Yii::t('website', 'search.result');

    $result = Yii::app()->db->createCommand('call search_procedure('."'".$q."'".')')->queryAll() ;
    $this->render('search', array('result'=>$result));     
}

Code is working perfectly with English language, but when user want to search with Arabic if we using var_dump($q); exit(); commands in search action, the $q variable is set to ØµØ¯Ø§Ø unknown characters so i couldn't use this parameter value in search procedure.

Can anyone help? thank you.

devOp
  • 3,150
  • 1
  • 18
  • 32
  • Can you post the header of the resulting html-code(data between -Tag) in the browser. I am sure we have a encoding problem here. – devOp Jul 13 '16 at 15:00
  • 1
    I'm sorry dear, the problem of text with strange characters is solved,Arabic text was appeared with var_dump function , i changed the system local settings in region and language at control panel, i changed current system local to one of Arabic countries, but i think that isn't the correct solution, – Jaber Abdallatef Jul 13 '16 at 15:59
  • but even the text show correctly at the controller, the stored procedure doesn't return any result with Arabic text ,i have tested that call at mysql workbench with Arabic and it returned correct results, can you help me? – Jaber Abdallatef Jul 13 '16 at 16:03
  • The problem is very specific. Please make sure that everything is encoded in utf-8 or other working encoding. Also test you search_procedure() very well. – devOp Jul 14 '16 at 07:38
  • thank you very much devOp, you are right, the problem was on search_procedure In parameters, i have declared search key as char(20) so it was only keep English strings, so i changed parameter type to varchar(20), and now it keep value on both Arabic and English – Jaber Abdallatef Jul 14 '16 at 13:20

1 Answers1

0

i have found solution for my problem as below : 1) first there was a problem with system local setting in my pc windows os, so i changed it to one of Arabic countries. 2) second there was a problem with IN parameter type in search_procedure,so i changed it to varchar(20).