1

I am trying to use onclick in PHP echo , I arrived at this error

Parse error: syntax error, unexpected 'OpenPopupCenter' (T_STRING) in C:\xampp\htdocs\e-vms\securitydashboard.php on line 229

My code looks like this

<?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die ('Cannot connect, Reason: '.mysqli_error());
$sql = "select * from new_reservation ";
$result = mysqli_query($con,$sql) or die ('Failed Query , Reason : '.mysqli_error($con));
while($row = mysqli_fetch_array($result)){

    $showData = "<TR valign=top>
<TD width=106 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp;&nbsp; {$row['visit_date']}</font></div>
</div>
</TD>
<TD width=134 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp; {$row['login_time']}</font></div>
</div>
</TD>
<TD width=148 height=26><div class=wpmd>
<div><font face=Verdana size=1><BR></font></div>
<div><font face=Verdana size=1>&nbsp;&nbsp;&nbsp; {$row['fullname']}</font></div>
</div>
</TD>
<TD width=160 height=26><div class=wpmd>
<div align=center><font face=Verdana size=1><BR></font></div>
<div align=center><font face=Verdana size=1>&nbsp;&nbsp; {$row['whom_tosee']}</font></div>
</div>
</TD>
<TD width=138 height=26><div class=wpmd>
<div>&nbsp;</div>
<div align=center><font face=Verdana><input type=image src=images/show_detailsbtn.png width=124 height=26 onclick="OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);" ></font></div>
</div>
</TD>
<TD width=163 height=26><div class=wpmd>
<div><BR></div>
<div>&nbsp;<font face=Verdana size=2>
    <input type=image src=images/signout_visitor.png width=121 height=27></font></div>
</div>
</TD>
</TR>
";
    echo $showData;

}
?>

What do i appear to be missing? Should I make some little adjustments it wont even open the window.

Sam
  • 31
  • 6
  • Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – 04FS Oct 22 '19 at 08:57
  • And go read up on some basics, please. https://www.php.net/manual/en/language.basic-syntax.phpmode.php There is no real need here to assemble this content in a variable first, only to then do nothing else but outputting it directly afterwards. You wouldn’t have that many problems with string delimiters and escaping in the first place without it. – 04FS Oct 22 '19 at 08:59

1 Answers1

1

Add \before ".

Replace

onclick="OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);"

by

onclick=\"OpenPopupCenter('e-vmsreserve.php', 'TEST!?', 1200, 600);\"
Reqven
  • 1,688
  • 1
  • 8
  • 13