[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

Unterminated String

I get unterminated string in my browser when I use the code below and it has something to do with the dollar signs I do not know how to have javascript translate the variables $prodhosts and $proshostserver.
SRCHOSTURLVERSIONLINKS is defined in another php file using define.


print "<tr><th><div align=\"center\">$prodhosts</th><th><input type=\"radio\" name=\"prod\" value=\"$prodhosts\"></div></th><th><div align=\"center\"><a href=\"javascript:void(0)\" onclick=\"window.open('". SRCHOSTURLVERSIONLINKS ."/$prodhosts/$prodhostsver',
'linkname','height=380, width=300,scrollbars=no')\">$prodhostsver</a></th></tr>\n";

Thanks



0
tronman12
Asked:
tronman12
  • 4
  • 2
  • 2
1 Solution
 
Beverley PortlockCommented:
Spacing it out to make it more readable gives this

          <th>
               <div align=\"center\">
                   $prodhosts
          </th>
          <th>
              <input type=\"radio\" name=\"prod\" value=\"$prodhosts\">
              </div>
          </th>
          <th>
              <div align=\"center\">
                 <a href=\"javascript:void(0)\" onclick=\"window.open('". SRCHOSTURLVERSIONLINKS ."/$prodhosts/$prodhostsver', 'linkname','height=380, width=300,scrollbars=no')\">
                     $prodhostsver
                 </a>
          </th>
       </tr>\n";


and it is immediately that you have a misplaced DIV. Also using single quotes for HTML attributes and doubles for PHP helps readability. Try this

<?php
error_reporting(E_ALL);
print "<tr>
          <th>
               <div align='center'>
                   $prodhosts
              </div>
          </th>
          <th>
              <input type='radio' name='prod' value='$prodhosts'>
          </th>
          <th>
              <div align='center'>
                 <a href='javascript:void(0); onclick='window.open(". SRCHOSTURLVERSIONLINKS ."/$prodhosts/$prodhostsver',\"linkname\",\"height=380, width=300,scrollbars=no\")'>
                     $prodhostsver
                 </a>
          </th>
       </tr>";

?>

Any closer?

0
 
tronman12Author Commented:
Thank you.  The unterminated string issue seemed to be resolved but now I am getting a syntax error.


0
 
James LooneySr. Programmer/AnalystCommented:
Try this

print '<tr>
<th>
'.$prodhosts.'</th>
<th>
<input type="radio" name="prod" value="'.$prodhosts.'">
</th>
<th>
<div align="center">
<a href="javascript:void(0)" onclick="window.open(\''. SRCHOSTURLVERSIONLINKS .'/'.$prodhosts.'/'.$prodhostsver.'\',\'linkname\',\'height=380, width=300,scrollbars=no\')">
'.$prodhostsver.'</a></th></tr>';

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tronman12Author Commented:
Thanks,  I tried that code and I get the unterminated string constant error again.  The first one was close it eliminated the string unterminated error but for some reason there is a syntax error in it.

0
 
James LooneySr. Programmer/AnalystCommented:
Weird. I don't get that error.

I do see that <div> is not closed so I took it out

<?php
print '<tr><th>'.$prodhosts.'</th><th><input type="radio" name="prod" value="'.$prodhosts.'"></th>
<th>
<a href="javascript:void(0)" onclick="window.open(\''. SRCHOSTURLVERSIONLINKS .'/'.$prodhosts.'/'.$prodhostsver.'\',\'linkname\',\'height=380, width=300,scrollbars=no\')">
'.$prodhostsver.'</a></th></tr>';
?>

Open in new window

0
 
Beverley PortlockCommented:
On inspection it looks like the javascript has a misplaced quote or two.

0
 
tronman12Author Commented:
YEAH!!! Thank you all for the help that last piece of code worked!!! This was tricky.
0
 
tronman12Author Commented:
Thank you very much  bportlock!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now