# Invalid EE conditional variable error - UPDATED

NEW INFO OK, I found that the error was being thrown by a custom exception built into expression engine that will do partial matches on variable names if it doesn't find the original one.

From libraries/Functions.php:

// There is a partial variable match being done
// because they are doing something like segment_11
// when there is no such variable but there is a segment_1
// echo  $x[$j]."\n<br />\n";
trigger_error('Invalid EE Conditional Variable: '.$matches[0][$i], E_USER_WARNING);


This code is part of a loop, essentially. We do have a variable called deal, which in certain cases evaluates to N (the element that's being processed by the template is not a deal). The error is only being thrown in cases where there is no deal_original_price (i.e. on rows that are not deals). I don't know why it's even trying to evaluate that, though, because the entire call is inside another conditional that only runs if deal is Y.

{if deal == "Y" AND coupon == "N"}
<tr data-deal_id="{deal_id}">
<td class="productPrice" style="vertical-align: top;">${deal_total}<br /> {if deal_original_price && deal_original_price != "" && deal_original_price <> deal_total} <span class="originalDealPrice">${deal_original_price}</span><br /><span id="modal_change">Why is there a price difference?</span>
{if:else}
<span id="modal_same">Pricing Terms & Conditions</span>
{/if}
</td>
</tr>
{/if}


Any ideas?

=====================================================================

I have the following html with embedded ee variable:

<td class="productPrice">${deal_total}<br />{if deal_original_price != ""}<span class="originalDealPrice">${deal_original_price}</span><br /><span class="removeItem"></span>{/if}</td>


It works, to some extent - it is displaying the correct value for deal_original_price. But when I check my error logs, I see this:

[06-May-2013 10:50:12] PHP User Warning: Invalid EE Conditional Variable: {if "N"original"$1.50" != ""} in C:\gitRepo\qo5phi\system\expressionengine\libraries\Functions.php on line 2843 (Here's what it actually looks like; SE is interpreting the ascii code for the dollar sign.) I'm new to EE; can anyone tell me what this means? (I realize it's just a warning, not a fatal error, but we're trying to clean up our code and don't want to do anything that throws warnings.) ETA [06-May-2013 11:07:47] PHP Parse error: syntax error, unexpected T_STRING in C:\gitRepo\qo5phi\system\expressionengine\libraries\Functions.php(680) : eval()'d code on line 194 [06-May-2013 11:07:47] PHP Stack trace: [06-May-2013 11:07:47] PHP 1. {main}() C:\gitRepo\qo5phi\index.php:0 [06-May-2013 11:07:47] PHP 2. require_once() C:\gitRepo\qo5phi\index.php:188 [06-May-2013 11:07:47] PHP 3. call_user_func_array() C:\gitRepo\qo5phi\system\codeigniter\system\core\CodeIgniter.php:311 [06-May-2013 11:07:47] PHP 4. EE->index() C:\gitRepo\qo5phi\system\codeigniter\system\core\CodeIgniter.php:311 [06-May-2013 11:07:47] PHP 5. EE_Core->generate_page() C:\gitRepo\qo5phi\system\expressionengine\controllers\ee.php:68 [06-May-2013 11:07:47] PHP 6. EE_Template->run_template_engine() C:\gitRepo\qo5phi\system\expressionengine\libraries\Core.php:643 [06-May-2013 11:07:47] PHP 7. EE_Template->fetch_and_parse() C:\gitRepo\qo5phi\system\expressionengine\libraries\Template.php:179 [06-May-2013 11:07:47] PHP 8. EE_Template->parse() C:\gitRepo\qo5phi\system\expressionengine\libraries\Template.php:231 [06-May-2013 11:07:47] PHP 9. EE_Template->advanced_conditionals() C:\gitRepo\qo5phi\system\expressionengine\libraries\Template.php:488 [06-May-2013 11:07:47] PHP 10. EE_Template->parse_template_php() C:\gitRepo\qo5phi\system\expressionengine\libraries\Template.php:3153 [06-May-2013 11:07:47] PHP 11. EE_Functions->evaluate() C:\gitRepo\qo5phi\system\expressionengine\libraries\Template.php:1579  • Have you tried to remove the embed and see if the same code works in just 1 template? Do you have PHP enabled for that template or the embed template? The parser seems to be failing when evaluating the PHP in the template. May 6 '13 at 16:10 • The thing is, the code IS working - it's parsing and displaying the value of the variable. It's just throwing a php warning on the conditional. May 6 '13 at 16:24 • I can't help without the answers to my questions. The point is not is it getting parsed with the correct value, but rather when it's parsing. I think it's failing because it's seeing the '$' (which is used in PHP). It's failing when PHP is evaluating the conditional a string and trying to convert it to PHP (logic). So my question is really trying to figure out why that variable is getting parsed and evaluating incorrectly. May 6 '13 at 16:31
• The value of the variable does not contain a dollar sign. That is assigned in the template. We have other variables that are assigned and formatted exactly the same way on the same template that do not throw errors. It's only the conditional that's causing the problem. May 6 '13 at 16:35
• And I need to correct the OP; in the error log, it doesn't actually display the dollar sign; the message uses the ascii code for it. It's SE that's interpreting the dollar sign. May 6 '13 at 16:36

You should use quotes with variable in condition to match string like:

<td class="productPrice">
${deal_total}<br /> {if "{deal_original_price}" != ""} <span class="originalDealPrice">${deal_original_price}
</span><br />
<span class="removeItem"></span>
{/if}
</td>

• Just a note, you really shouldn't need to do this in all cases. This is really only used in instances when the variable in the conditional is parsed before the conditional itself. May 6 '13 at 16:06
• I just tried that; got a huge mess of an error. Will add to OP. May 6 '13 at 16:08
• Yes Justin, quotes will not be needed while comparing number, single word etc. In case of string, it would always be workable. May 6 '13 at 16:14

Another short & sweet way to write the conditional is:

{if deal_original_price}STUFF HERE{/if}