Announcement

Collapse
No announcement yet.

IF condition not running

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • IF condition not running

    Hi all,

    i have problem IF condition, on scriuptcase

    On control (validate), i have IF condition to control query

    ===================================
    $nama_user = sc_sql_injection({nama_user});
    $hak_akses = sc_sql_injection({hak_akses});
    $sql='';

    if ({hak_akses} == 'All')
    {
    sc_error_message ("==");
    $sql = "update dbo.master_users_apps set
    priv_access='Y',
    priv_insert='Y',
    priv_delete='Y',
    priv_update='Y',
    priv_export='Y',
    Priv_print='Y'
    where login= ". $nama_user;
    }
    else
    {
    sc_error_message ("<>");
    $sql = "update a set
    priv_access = 'Y',
    a.priv_insert = 'Y',
    a.priv_delete = 'Y',
    a.priv_update = 'Y',
    a.priv_export = 'Y',
    a.priv_print = 'Y'
    from dbo.master_users_apps a
    inner join dbo.master_apps b
    on a.app_name = b.app_name
    where b.description= $hak_akses and a.login= ". $nama_user;

    }

    sc_lookup(rs, $sql);

    ===========================
    if condition
    if ({hak_akses} == 'All') this output from sc_error message show <> (input data = All)
    but if i use = (single =) output from sc_error_message still sgow == ( input data <> All)

    why function IF condition not running in my case ?

    Regards
    Iwan Setiawan

  • #2
    Are you sure that {hak_akses} truly equals 'All'? Is it possible there are leading or trailing blanks? Do you get the same result if you say:

    Code:
    if (trim({hak_akses}) == 'All')        // Remove any leading / trailing whitespace characters
    {
    ........

    Comment


    • #3
      I have similar issues and reported that long time ago. In some cases macro's within if/else are always executed or it simply doesn't matter. YOu could try to apply the if to a php variable and then test that one of.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        Please check the generated source code (use view source) and see what is generated. This should give you a clue of what is wrongly converted.
        You can find your code back in the generated source although it is not exactly the same there.

        Comment


        • #5
          Hi Adz1111, i try you suggestion. but output SC stilll wrong. I make sure data is 'All' (without ' ) but IF condition still not correct.

          Comment


          • #6
            Hi rr,
            i try show source code :
            but i not understand what is wrong with my code

            ===================================
            1285| if ($this->hak_akses == 'All')
            1286| {
            1287|
            1288| if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
            1289| if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= "TRUE ==";
            1290| if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6))
            1291| {
            1292| $sErrorIndex = ('submit_form' == $this->NM_ajax_opcao) ? 'geral_security_user_group_control' : substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
            1293| $this->NM_ajax_info['errList'][$sErrorIndex][] = "TRUE ==";
            1294| }
            1295| ;
            1296| $sql = "update dbo.master_users_apps set
            1297| priv_access='Y',
            1298| priv_insert='Y',
            1299| priv_delete='Y',
            1300| priv_update='Y',
            1301| priv_export='Y',
            1302| Priv_print='Y'
            1303| where login= ". $this->nama_user;
            1304| }
            1305| else
            1306| {
            1307|
            1308| if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
            1309| if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= "FALSE <>";
            1310| if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6))
            1311| {
            1312| $sErrorIndex = ('submit_form' == $this->NM_ajax_opcao) ? 'geral_security_user_group_control' : substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
            1313| $this->NM_ajax_info['errList'][$sErrorIndex][] = "FALSE <>";
            1314| }
            1315| ;
            1316| $sql = "update a set
            1317| priv_access = 'Y',
            1318| a.priv_insert = 'Y',
            1319| a.priv_delete = 'Y',
            1320| a.priv_update = 'Y',
            1321| a.priv_export = 'Y',
            1322| a.priv_print = 'Y'
            1323| from dbo.master_users_apps a
            1324| inner join dbo.master_apps b
            1325| on a.app_name = b.app_name
            1326| where b.description= $this->hak_akses and a.login= ". $this->nama_user;
            1327|
            1328| }

            Comment


            • #7
              Hi Aducom,
              i already make sure my code running well in manually script PHP (not in SC)

              Comment


              • #8
                http://php.net/manual/en/language.op...comparison.php
                Are you sure that {hak_akses} is not without spaces and that it is a string?
                YOu can check this with gettype (see http://php.net/manual/en/function.gettype.php)

                Comment


                • #9
                  Iwan

                  Also, are you able to debug the generated code at that point - in particular view the contents of $this->hak_akses?

                  Comment

                  Working...
                  X