Announcement

Collapse
No announcement yet.

Scope of variable issue?

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

  • Scope of variable issue?

    I have the following routine in my library:

    Code:
    function dbgettemplate($shopid, $templateid, $parms)
    {
    	echo 'loading data for'.$shopid.' with template '.$templateid;
        $check_sql = "SELECT templatetext from ndtemplate where shopid='$shopid' and templateid='$templateid'";
        sc_select(rs, $check_sql);	
        $tpl=$rs->fields[0];
    
    	while ($kwd = current($parms)) {
    	  $key=key($parms); 
    	  $tpl=str_ireplace('['.$key.']', $kwd, $tpl);
    	  next($parms);
    	}
    	echo '...<br>'.$tpl;
        return $tpl;
    }
    The function is that with replacing a template is filled with data. The 'fun' part is the following result of my debug log:

    loading data forgeneric with template generic_footer_nl (mysqlt): SELECT templatetext from ndtemplate where shopid='aducom' and templateid='generic_footer_nl' ...
    loading data forgeneric with template generic_footer_nl (mysqlt): SELECT templatetext from ndtemplate where shopid='aducom' and templateid='generic_footer_nl' ...

    What I can see is that the variable $shop is loaded with 'generic' but that the content when used in the sql statement is 'aducom'. Appearantly this value is extracted from another object or so?

    It works if i use:

    Code:
        $check_sql = "SELECT templatetext from ndtemplate where shopid='".$shopid."' and templateid='$templateid'";
    but that should not be necessary
    Last edited by aducom; 07-02-2014, 06:20 AM.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

  • #2
    Hello,

    Issue reported to our bugs team.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      When you try ...

      Code:
      echo "loading data for " . $shopid. " with template " .$templateid;
      ... the result is the same?
      Best regards: - Reinhard -

      I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

      Comment


      • #4
        Originally posted by RHS View Post
        When you try ...

        Code:
        echo "loading data for " . $shopid. " with template " .$templateid;
        ... the result is the same?
        No the second sample works.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment

        Working...
        X