Page 1 of 1

Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 3:21 pm
by rstuttle
Hello,

I am trying to setup a shopping cart and I am getting an error in a module. The error reported is:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in modules.php on line 173

The third line in the code snippet below is line 173 and if the entire snippet is removed from the code, the problem disappears. Unfortunately, removing the code is not a desirable solution. Can someone point out the problem to me? Thank you.

Code: Select all

     if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
        if ($module->check() > 0) {
          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . ''">' . "n";
        } else {
          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "n";
        }
      } else {
        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . ''">' . "n";
      }

Re: Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 3:31 pm
by Weirdan
With proper highlighting you can see the error yourself, I guess.

Re: Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 3:54 pm
by rstuttle
Thanks for the quick reply, Weirdan.

I do wish I could see the error, but I am not a php programmer. I assume that the error has to do with misplacement of quotes, but I am too ignorant of php syntax to see what is wrong. I am hoping that someone who is conversant with php can point out the obvious to me.

Re: Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 4:00 pm
by Mark Baker

Code: Select all

 
echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '">' . "\n";
 
I'm assuming that the "n" at the end should be "\n"


Look at the difference in colouring between your line 3 and the above

Re: Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 4:03 pm
by Ziq

Code: Select all

 
if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
        if ($module->check() > 0) {
          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '">' . "n";
        } else {
          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "n";
        }
      } else {
        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '">' . "n";
      }
 

Re: Can someone spot the syntax error in this snippet?

Posted: Sun Feb 08, 2009 4:46 pm
by rstuttle
Your English is fine, and your php excellent!
Thank you!