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



tronman12Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.