Scope of variable issue?

I have the following routine in my library:


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:


    $check_sql = "SELECT templatetext from ndtemplate where shopid='".$shopid."' and templateid='$templateid'";

but that should not be necessary

Hello,

Issue reported to our bugs team.

regards,
Bernhard Bernsmann

When you try …


echo "loading data for " . $shopid. " with template " .$templateid;

… the result is the same?

[QUOTE=RHS;24946]When you try …


echo "loading data for " . $shopid. " with template " .$templateid;

… the result is the same?[/QUOTE]

No the second sample works.